/** set the Atoms for a particular residue position. * Requires that atom.getParent returns the correct group! * take care during cloning of atoms. Best to use StructureTools.cloneCaAtoms(); * * @param strBuf * @param i * @param ca * @param j */ private void setStrBuf(Atom[] strBuf, int i, Atom[] ca, int j) { // TODO Auto-generated method stub //TODO Group parent = ca[j].getGroup(); int pos = 0; String atomName = ca[j].getName(); Atom a = null; a= parent.getAtom(atomName); if ( a != null){ strBuf[i]=a; } else { // probably a GLY and no CB was found... //e.printStackTrace(); } strBuf[i+pos] = a; pos++; }
/** * Gets the radius for given nucleotide atom * @param atom * @return */ private static double getRadiusForNucl(NucleotideImpl nuc, Atom atom) { if (atom.getElement().equals(Element.H)) return Element.H.getVDWRadius(); if (atom.getElement().equals(Element.D)) return Element.D.getVDWRadius(); if (atom.getElement()==Element.C) return NUC_CARBON_VDW; if (atom.getElement()==Element.N) return NUC_NITROGEN_VDW; if (atom.getElement()==Element.P) return PHOSPHOROUS_VDW; if (atom.getElement()==Element.O) return OXIGEN_VDW; logger.info("Unexpected atom "+atom.getName()+" for nucleotide "+nuc.getPDBName()+", assigning its standard vdw radius"); return atom.getElement().getVDWRadius(); }
/** * Returns the unit vector of vector a . * * @param a * an Atom object * @return an Atom object */ public static final Atom unitVector(Atom a) { double amount = amount(a) ; double[] coords = new double[3]; coords[0] = a.getX() / amount ; coords[1] = a.getY() / amount ; coords[2] = a.getZ() / amount ; a.setCoords(coords); return a; }
Group g = a.getGroup(); int seri = a.getPDBserial() ; String serial = String.format("%5d",seri); String fullName = formatAtomName(a); Character altLoc = a.getAltLoc(); if ( altLoc == null) altLoc = ' '; resseq = String.format("%4s",pdbcode)+" "; String x = String.format("%8s",d3.format(a.getX())); String y = String.format("%8s",d3.format(a.getY())); String z = String.format("%8s",d3.format(a.getZ())); String occupancy = String.format("%6s",d2.format(a.getOccupancy())) ; String tempfactor = String.format("%6s",d2.format(a.getTempFactor())); s.append(tempfactor); Element e = a.getElement();
Atom atom = new AtomImpl(); Group altGroup = null; atom.setPDBserial(serialNumber); atom.setName(atomName.trim()); atom.setElement(Element.valueOfIgnoreCase(element)); if(alternativeLocationId==MmtfStructure.UNAVAILABLE_CHAR_VALUE){ alternativeLocationId = ' '; atom.setAltLoc(alternativeLocationId); } else { atom.setAltLoc(Character.valueOf(' ')); atom.setX(x); atom.setY(y); atom.setZ(z); atom.setOccupancy(occupancy); atom.setTempFactor(temperatureFactor); atom.setCharge((short) charge); if (altGroup == null) { group.addAtom(atom); if (!group.hasAtom(atom.getName())) { if (group.getPDBName().equals(atom.getGroup().getPDBName())) {
for (Atom atom : atomsInGroup){ char altLoc = MmtfStructure.UNAVAILABLE_CHAR_VALUE; if(atom.getAltLoc()!=null){ if(atom.getAltLoc().charValue()!=' '){ altLoc=atom.getAltLoc().charValue(); mmtfDecoderInterface.setAtomInfo(atom.getName(), atom.getPDBserial(), altLoc, (float) atom.getX(), (float) atom.getY(), (float) atom.getZ(), atom.getOccupancy(), atom.getTempFactor(), atom.getElement().toString(), atom.getCharge()); addBonds(atom, atomsInGroup, allAtoms);
try{ PDBFileReader read=new PDBFileReader(); Structure pdb=read.getStructure(filename); System.out.println("PDB code :"+pdb.getPDBCode()); List chains=Collections.synchronizedList(new ArrayList()); chains=pdb.getChains(); for(Iterator iter=chains.iterator();iter.hasNext();){ Chain c=(Chain)(iter.next()); System.out.println("Chain :"+c.getName()+"\n"+"Seq aa :"+c.getAtomSequence()); for(int j=0;j<c.getAtomLength();j++){ for (int k=0; k < c.getAtomGroup(j).size(); k++ ){ Atom a=c.getAtomGroup(j).getAtom(k); System.out.println("Name : "+a.getName()+" X : "+a.getX()+" Y : "+a.getY()+" Z : "+a.getZ()); } }
for(Atom a: thisGroup.getAtoms()){ String spaceX = getSpace(10, df.format(a.getX())); String spaceY = getSpace(10, df.format(a.getY())); String spaceZ = getSpace(10, df.format(a.getZ())); String spaceEle = getSpace(4, a.getElement().toString()); atomList.append(spaceX+df.format(a.getX())+spaceY+df.format(a.getY())+spaceZ+df.format(a.getZ())+" "+a.getElement().toString()+spaceEle+"0 0 0 0 0 0 0 0 0 0 0 0\n"); for(Bond b: a.getBonds()){ Atom otherAtom = b.getOther(a); if(atoms.indexOf(otherAtom)>=atoms.indexOf(a)){
a.setPDBserial(Integer.parseInt(atom.getId())); a.setName(atom.getLabel_atom_id()); a.setX(x); a.setY(y); a.setZ(z); a.setOccupancy(occupancy); a.setTempFactor(temp); a.setAltLoc(new Character(alt.charAt(0))); } else { a.setAltLoc(new Character(' ')); logger.info("Element {} was not recognised as a BioJava-known element, the element will be represented as the generic element {}", atom.getType_symbol(), Element.R.name()); a.setElement(element);
/** * Returns the List of Groups of the corresponding representative Atom * array. The representative Atom array needs to fulfill: no two Atoms are * from the same Group and Groups are sequential (connected in the original * Structure), except if they are from different Chains. * * @param rAtoms * array of representative Atoms (CA, P, etc). * @return List of Groups */ public static List<Group> getGroups(Atom[] rAtoms) { List<Group> groups = new ArrayList<Group>(rAtoms.length); for (Atom a : rAtoms) { Group g = a.getGroup(); if (g != null) groups.add(g); else logger.info("Group not found for representative Atom {}", a); } return groups; }
if (atom.getElement()==null) { logger.warn("Unrecognised atom "+atom.getName()+" with serial "+atom.getPDBserial()+ ", assigning the default vdw radius (Nitrogen vdw radius)."); return Element.N.getVDWRadius(); Group res = atom.getGroup(); logger.warn("Unknown parent residue for atom "+atom.getName()+" with serial "+ atom.getPDBserial()+", assigning its default vdw radius"); return atom.getElement().getVDWRadius(); return atom.getElement().getVDWRadius();
/** * {@inheritDoc} */ @Override public void addAtom(Atom atom){ atom.setGroup(this); atoms.add(atom); // TODO this check is useless, coords are always !=null since they are initialized to 0,0,0 in AtomImpl constructor. We need to review this - JD 2016-09-14 if (atom.getCoordsAsPoint3d() != null){ // we have got coordinates! setPDBFlag(true); } if (atomNameLookup != null){ Atom existingAtom = atomNameLookup.put(atom.getName(), atom); // if an atom with same name is added to the group that has to be some kind of problem, // we need to warn properly if (existingAtom != null) { String altLocStr = ""; char altLoc = atom.getAltLoc(); if (altLoc != ' ') altLocStr = "(alt loc '" + altLoc + "')"; logger.warn("An atom with name " + atom.getName() + " " + altLocStr + " is already present in group: " + this.toString() + ". The atom with serial " + atom.getPDBserial() + " will be ignored in look-ups."); } } };
private static Atom[] getAtoms(Atom[] ca, int[] positions, int length, boolean clone) { List<Atom> atoms = new ArrayList<Atom>(); for (int i = 0; i < length; i++) { int p = positions[i]; Atom a; if (clone) { a = (Atom) ca[p].clone(); a.setGroup((Group) ca[p].getGroup().clone()); } else { a = ca[p]; } atoms.add(a); } return atoms.toArray(new Atom[atoms.size()]); }
private static final Atom[] getAllNonHAtomArray(Structure s, boolean hetAtoms, AtomIterator iter) { List<Atom> atoms = new ArrayList<Atom>(); while (iter.hasNext()) { Atom a = iter.next(); if (a.getElement() == Element.H) continue; Group g = a.getGroup(); if (g.isWater()) continue; if (!hetAtoms && g.getType().equals(GroupType.HETATM)) continue; atoms.add(a); } return atoms.toArray(new Atom[atoms.size()]); }
/** * {@inheritDoc} */ @Override public void setAtoms(List<Atom> atoms) { // important we are resetting atoms to a new list, we need to reset the lookup too! if ( atomNameLookup != null) atomNameLookup.clear(); for (Atom a: atoms){ a.setGroup(this); if ( atomNameLookup != null) atomNameLookup.put(a.getName(),a); } this.atoms = atoms; if (!atoms.isEmpty()) { pdb_flag = true; } }
public boolean hasContact(Atom atom1, Atom atom2) { return hasContact( new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()), new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) ); }
/** * {@inheritDoc} */ @Override public Atom getAtom(String name) { if ( atomNameLookup != null) return atomNameLookup.get(name); else { /** This is the performance penalty we pay for NOT using the atomnameLookup in PerformanceBehaviour.LESS_MEMORY_SLOWER_PERFORMANCE */ for (Atom a : atoms) { if (a.getName().equals(name)) { return a; } } return null; } }
private int getGroupNoHSize() { int count = 0; for (Atom atom:g.getAtoms()) { if (atom.getElement()!=Element.H) count++; } return count; }