public static String getFullAtomSequence ( List < Group > groups , Map < Integer , Integer > positionIndex , boolean isNucleotideChain ) { StringBuffer sequence = new StringBuffer ( ) ; int seqIndex = 0 ; // track sequence.length() for ( int i = 0 ; i < groups . size ( ) ; i ++ ) { Group g = groups . get ( i ) ; if ( g instanceof AminoAcid ) { AminoAcid a = ( AminoAcid ) g ; char oneLetter = a . getAminoType ( ) ; if ( oneLetter == ' ' ) oneLetter = ' ' ; positionIndex . put ( seqIndex , i ) ; sequence . append ( oneLetter ) ; seqIndex ++ ; } else { // exclude solvents if ( g . isWater ( ) ) continue ; // exclude metals if ( g . size ( ) == 1 ) { Atom a = g . getAtom ( 0 ) ; if ( a == null ) continue ; if ( a . getElement ( ) . isMetal ( ) ) continue ; } ChemComp cc = g . getChemComp ( ) ; if ( cc == null ) { logger . debug ( "No chem comp available for group {}" , g . toString ( ) ) ; // not sure what to do in that case! continue ; } if ( ResidueType . lPeptideLinking . equals ( cc . getResidueType ( ) ) || PolymerType . PROTEIN_ONLY . contains ( cc . getPolymerType ( ) ) || PolymerType . POLYNUCLEOTIDE_ONLY . contains ( cc . getPolymerType ( ) ) ) { //System.out.println(cc.getOne_letter_code()); String c = cc . getOne_letter_code ( ) ; if ( c . equals ( "?" ) ) { if ( isNucleotideChain && PolymerType . POLYNUCLEOTIDE_ONLY . contains ( cc . getPolymerType ( ) ) ) { // the way to represent unknown nucleotides is with 'N', see https://en.wikipedia.org/wiki/Nucleic_acid_notation c = "N" ; } else { c = "X" ; } } // For some unusual cases the het residue can map to 2 or more standard aas and thus give an // insertion of length >1. // e.g. 1: SUI maps to DG (in 1oew,A) // e.g. 2: NRQ maps to MYG (in 3cfh,A) if ( c . length ( ) > 1 ) { logger . info ( "Group '{}' maps to more than 1 standard aminoacid: {}." , g . toString ( ) , c ) ; } // because of the mapping to more than 1 aminoacid, we have // to loop through it (99% of cases c will have length 1 anyway) for ( int cIdx = 0 ; cIdx < c . length ( ) ; cIdx ++ ) { positionIndex . put ( seqIndex , i ) ; sequence . append ( c . charAt ( cIdx ) ) ; seqIndex ++ ; } } else { logger . debug ( "Group {} is not lPeptideLinked, nor PROTEIN_ONLY, nor POLYNUCLEOTIDE_ONLY" , g . toString ( ) ) ; continue ; } //sequence.append("X"); } } return sequence . toString ( ) ; }
Returns the full sequence of the Atom records of a parent with X instead of HETATMSs . The advantage of this is that it allows us to also align HETATM groups back to the SEQRES .