private Group getNewGroup ( String recordName , Character aminoCode1 , long seq_id , String groupCode3 ) { Group g = ChemCompGroupFactory . getGroupFromChemCompDictionary ( groupCode3 ) ; if ( g != null && ! g . getChemComp ( ) . isEmpty ( ) ) { if ( g instanceof AminoAcidImpl ) { AminoAcidImpl aa = ( AminoAcidImpl ) g ; aa . setId ( seq_id ) ; } else if ( g instanceof NucleotideImpl ) { NucleotideImpl nuc = ( NucleotideImpl ) g ; nuc . setId ( seq_id ) ; } else if ( g instanceof HetatomImpl ) { HetatomImpl het = ( HetatomImpl ) g ; het . setId ( seq_id ) ; } return g ; } Group group ; if ( recordName . equals ( "ATOM" ) ) { if ( StructureTools . isNucleotide ( groupCode3 ) ) { // it is a nucleotide NucleotideImpl nu = new NucleotideImpl ( ) ; group = nu ; nu . setId ( seq_id ) ; } else if ( aminoCode1 == null || aminoCode1 == StructureTools . UNKNOWN_GROUP_LABEL ) { HetatomImpl h = new HetatomImpl ( ) ; h . setId ( seq_id ) ; group = h ; } else { AminoAcidImpl aa = new AminoAcidImpl ( ) ; aa . setAminoType ( aminoCode1 ) ; aa . setId ( seq_id ) ; group = aa ; } } else { if ( StructureTools . isNucleotide ( groupCode3 ) ) { // it is a nucleotide NucleotideImpl nu = new NucleotideImpl ( ) ; group = nu ; nu . setId ( seq_id ) ; } else if ( aminoCode1 != null ) { AminoAcidImpl aa = new AminoAcidImpl ( ) ; aa . setAminoType ( aminoCode1 ) ; aa . setId ( seq_id ) ; group = aa ; } else { HetatomImpl h = new HetatomImpl ( ) ; h . setId ( seq_id ) ; group = h ; } } return group ; }
initiate new group either Hetatom Nucleotide or AminoAcid