/** returns and identical copy of this Group object . * @return and identical copy of this Group object */ @Override public Object clone() { HetatomImpl n = new HetatomImpl(); n.setPDBFlag(has3D()); n.setResidueNumber(residueNumber); n.setPDBName(getPDBName()); //clone atoms and bonds. cloneAtomsAndBonds(n); // copying the alt loc groups if present, otherwise they stay null if (altLocs!=null) { for (Group altLocGroup:this.altLocs) { Group nAltLocGroup = (Group)altLocGroup.clone(); n.addAltLoc(nAltLocGroup); } } if (chemComp!=null) n.setChemComp(chemComp); return n; }
/** attempts to reduce the memory imprint of this group by trimming * all internal Collection objects to the required size. * */ @Override public void trimToSize(){ if ( atoms instanceof ArrayList<?>) { ArrayList<Atom> myatoms = (ArrayList<Atom>) atoms; myatoms.trimToSize(); } if ( altLocs instanceof ArrayList<?>){ ArrayList<Group> myAltLocs = (ArrayList<Group>) altLocs; myAltLocs.trimToSize(); } if ( hasAltLoc()) { for (Group alt : getAltLocs()){ alt.trimToSize(); } } // now let's fit the hashmaps to size properties = new HashMap<String, Object>(properties); if ( atomNameLookup != null) atomNameLookup = new HashMap<String,Atom>(atomNameLookup); }
@Override public boolean isAminoAcid() { ChemComp cc = getChemComp(); if ( cc == null) return getType().equals(GroupType.AMINOACID); ResidueType rt = cc.getResidueType(); if ( rt.equals(ResidueType.nonPolymer)) return false; PolymerType pt = rt.getPolymerType(); return PolymerType.PROTEIN_ONLY.contains(pt); }
} else if ( g instanceof HetatomImpl) { HetatomImpl het = (HetatomImpl)g; het.setId(seq_id); HetatomImpl h = new HetatomImpl(); h.setId(seq_id); group = h; group = aa ; } else { HetatomImpl h = new HetatomImpl(); h.setId(seq_id); group = h;
g = new HetatomImpl();
private int getInternalNr(Group atomG) { if ( atomG.getType().equals(GroupType.AMINOACID)) { AminoAcidImpl aa = (AminoAcidImpl) atomG; return new Long(aa.getId()).intValue(); } else if ( atomG.getType().equals(GroupType.NUCLEOTIDE)) { NucleotideImpl nu = (NucleotideImpl) atomG; return new Long(nu.getId()).intValue(); } else { HetatomImpl he = (HetatomImpl) atomG; return new Long(he.getId()).intValue(); } }
@Override public Group getAltLocGroup(Character altLoc) { Atom a = getAtom(0); if ( a == null) { return null; } // maybe the alt loc group in question is myself if (a.getAltLoc().equals(altLoc)) { return this; } if (altLocs == null || altLocs.isEmpty()) return null; for (Group group : altLocs) { if (group.getAtoms().isEmpty()) continue; // determine this group's alt-loc character code by looking // at its first atom's alt-loc character Atom b = group.getAtom(0); if ( b == null) continue; if (b.getAltLoc().equals(altLoc)) { return group; } } return null; }
/** initiate new resNum, either Hetatom, Nucleotide, or AminoAcid */ private Group getNewGroup(String recordName,Character aminoCode1, String aminoCode3) { Group g = ChemCompGroupFactory.getGroupFromChemCompDictionary(aminoCode3); if ( g != null && !g.getChemComp().isEmpty()) return g; Group group; if (aminoCode1 == null || StructureTools.UNKNOWN_GROUP_LABEL == aminoCode1 ){ group = new HetatomImpl(); } else if(StructureTools.isNucleotide(aminoCode3)) { // it is a nucleotide NucleotideImpl nu = new NucleotideImpl(); group = nu; } else { AminoAcidImpl aa = new AminoAcidImpl() ; aa.setAminoType(aminoCode1); group = aa ; } // System.out.println("new resNum type: "+ resNum.getType() ); return group ; }
@Override public boolean isNucleotide() { ChemComp cc = getChemComp(); if ( cc == null) return getType().equals(GroupType.NUCLEOTIDE); ResidueType rt = cc.getResidueType(); if ( rt.equals(ResidueType.nonPolymer)) return false; PolymerType pt = rt.getPolymerType(); return PolymerType.POLYNUCLEOTIDE_ONLY.contains(pt); }
break; default: group = new HetatomImpl(); break;
@Override public boolean isPolymeric() { ChemComp cc = getChemComp(); if ( cc == null) return getType().equals(GroupType.AMINOACID) || getType().equals(GroupType.NUCLEOTIDE); ResidueType rt = cc.getResidueType(); if ( rt.equals(ResidueType.nonPolymer)) return false; PolymerType pt = rt.getPolymerType(); return PolymerType.PROTEIN_ONLY.contains(pt) || PolymerType.POLYNUCLEOTIDE_ONLY.contains(pt) || ResidueType.lPeptideLinking.equals(rt); }
HetatomImpl h = new HetatomImpl(); g = h;