@ SuppressWarnings ( "unchecked" ) protected void calculateIndirectAmbiguities ( ) { Map < NucleotideCompound , List < NucleotideCompound > > equivalentsMap = new HashMap < NucleotideCompound , List < NucleotideCompound > > ( ) ; List < NucleotideCompound > ambiguousCompounds = new ArrayList < NucleotideCompound > ( ) ; for ( NucleotideCompound compound : getAllCompounds ( ) ) { if ( ! compound . isAmbiguous ( ) ) { continue ; } ambiguousCompounds . add ( compound ) ; } for ( NucleotideCompound sourceCompound : ambiguousCompounds ) { Set < NucleotideCompound > compoundConstituents = sourceCompound . getConstituents ( ) ; for ( NucleotideCompound targetCompound : ambiguousCompounds ) { Set < NucleotideCompound > targetConstituents = targetCompound . getConstituents ( ) ; if ( targetConstituents . containsAll ( compoundConstituents ) ) { NucleotideCompound lcSourceCompound = toLowerCase ( sourceCompound ) ; NucleotideCompound lcTargetCompound = toLowerCase ( targetCompound ) ; //equivalentsMap.put(sourceCompound, targetCompound); // equivalentsMap.put(sourceCompound, lcTargetCompound); checkAdd ( equivalentsMap , sourceCompound , targetCompound ) ; checkAdd ( equivalentsMap , sourceCompound , lcTargetCompound ) ; checkAdd ( equivalentsMap , targetCompound , sourceCompound ) ; checkAdd ( equivalentsMap , lcTargetCompound , sourceCompound ) ; checkAdd ( equivalentsMap , lcSourceCompound , targetCompound ) ; checkAdd ( equivalentsMap , lcSourceCompound , lcTargetCompound ) ; } } } //And once it's all done start adding them to the equivalents map for ( NucleotideCompound key : equivalentsMap . keySet ( ) ) { List < NucleotideCompound > vals = equivalentsMap . get ( key ) ; for ( NucleotideCompound value : vals ) { addEquivalent ( ( C ) key , ( C ) value ) ; addEquivalent ( ( C ) value , ( C ) key ) ; } } }
Loops through all known nucleotides and attempts to find which are equivalent to each other . Also takes into account lower casing nucleotides as well as upper - cased ones .