public void computeMolecularWeight ( ElementTable eTable ) { this . aaSymbol2MolecularWeight = new HashMap < Character , Double > ( ) ; for ( AminoAcidComposition a : aminoacid ) { //Check to ensure that the symbol is of single character if ( a . getSymbol ( ) . length ( ) != 1 ) { throw new Error ( a . getSymbol ( ) + " is not allowed. Symbols must be single character.\r\nPlease check AminoAcidComposition XML file" ) ; } //Check to ensure that the symbols are not repeated char c = a . getSymbol ( ) . charAt ( 0 ) ; if ( this . aaSymbol2MolecularWeight . keySet ( ) . contains ( c ) ) { throw new Error ( "Symbol " + c + " is repeated.\r\n" + "Please check AminoAcidComposition XML file to ensure there are no repeated symbols. Note that this is case-insensitive.\r\n" + "This means that having 'A' and 'a' would be repeating." ) ; } double total = 0.0 ; if ( a . getElementList ( ) != null ) { for ( Name2Count element : a . getElementList ( ) ) { element . getName ( ) ; if ( eTable . getElement ( element . getName ( ) ) == null ) { throw new Error ( "Element " + element . getName ( ) + " could not be found. " + "\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml." ) ; } eTable . getElement ( element . getName ( ) ) . getMass ( ) ; total += eTable . getElement ( element . getName ( ) ) . getMass ( ) * element . getCount ( ) ; } } if ( a . getIsotopeList ( ) != null ) { for ( Name2Count isotope : a . getIsotopeList ( ) ) { isotope . getName ( ) ; if ( eTable . getIsotope ( isotope . getName ( ) ) == null ) { throw new Error ( "Isotope " + isotope . getName ( ) + " could not be found. " + "\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml." ) ; } eTable . getIsotope ( isotope . getName ( ) ) . getMass ( ) ; total += eTable . getIsotope ( isotope . getName ( ) ) . getMass ( ) * isotope . getCount ( ) ; } } c = a . getSymbol ( ) . charAt ( 0 ) ; this . aaSymbol2MolecularWeight . put ( c , total ) ; } generatesAminoAcidCompoundSet ( ) ; }
Computes and store the molecular weight of each amino acid by its symbol in aaSymbol2MolecularWeight .