package username.genetics; /** * A sample non-trivial metric for costing changes in DNA * sequences. * * @author Gene Geneticist * @author Gena Geneticist * @author Samuel A. Rebelsky * @version 1.0 of April 2006 */ public class SampleMetric implements CostMetric { /** * The cost for deleting character sc from source. */ public int deleteCost(char sc) { // It is slightly cheaper to delete A if ((sc == 'A') || (sc == 'a')) { return 2; } // It is significantly more expensive to delete G else if ((sc == 'G') || (sc == 'g')) { return 8; } // Default: Relatively cheap else { return 3; } } // deleteCost(char) /** * The cost for inserting character tc into source. */ public int insertCost(char tc) { // Inserting C is cheap if ((tc == 'C') || (tc == 'c')) { return 3; } // Inserting is generally expensive. else { return 9; } } // insertCost(char) /** * The cost for changing char sc of source to char tc of target. */ public int replaceCost(char sc, char tc) { // Replacing characters with their complement is cheap. if ( (((sc == 'a') || (sc == 'A')) && ((tc == 't') || (tc == 'T'))) || (((sc == 't') || (sc == 'T')) && ((tc == 'a') || (tc == 'A'))) || (((sc == 'c') || (sc == 'C')) && ((tc == 'g') || (tc == 'G'))) || (((sc == 'g') || (sc == 'G')) && ((tc == 'c') || (tc == 'C'))) ) { return 1; } // Actually, replacmeent is still pretty cheap else { return 2; } } // replaceCost(char, char) } // interface SampleMetric