private static List<Number> getAtomCharges(Group group) { // The list to store the answer List<Number> outArr = new ArrayList<Number>(); // Get the atom charge Information for(Atom a: group.getAtoms()){ outArr.add(a.getCharge()); } return outArr; }
private int getGroupNoHSize() { int count = 0; for (Atom atom:g.getAtoms()) { if (atom.getElement()!=Element.H) count++; } return count; }
/** * Calculates the number of non-Hydrogen atoms in the given group * @param g * @return */ private static int getSizeNoH(Group g) { int size = 0; for (Atom a:g.getAtoms()) { if (a.getElement()!=Element.H) size++; } return size; }
/** * Get a list of atoms for a group. Only add each atom once. * @param inputGroup the Biojava Group to consider * @return the atoms for the input Biojava Group */ public static List<Atom> getAtomsForGroup(Group inputGroup) { Set<Atom> uniqueAtoms = new HashSet<Atom>(); List<Atom> theseAtoms = new ArrayList<Atom>(); for(Atom a: inputGroup.getAtoms()){ theseAtoms.add(a); uniqueAtoms.add(a); } List<Group> altLocs = inputGroup.getAltLocs(); for(Group thisG: altLocs){ for(Atom a: thisG.getAtoms()){ if(uniqueAtoms.contains(a)){ continue; } theseAtoms.add(a); } } return theseAtoms; }
/** * * @param group a {@link Group}. * @return all atom names of the group. */ public static List<String> getAtomNames(Group group) { List<Atom> atoms = group.getAtoms(); if (atoms == null) { return Collections.emptyList(); } int n = atoms.size(); List<String> ret = new ArrayList<String>(n); for (int i=0; i<n; i++) { ret.add(atoms.get(i).getName()); } return ret; }
/** * Returns and array of all atoms of the chain, including * Hydrogens (if present) and all HETATOMs. Waters are not included. * * @param c * input chain * @return all atom array */ public static final Atom[] getAllAtomArray(Chain c) { List<Atom> atoms = new ArrayList<Atom>(); for (Group g : c.getAtomGroups()) { if (g.isWater()) continue; for (Atom a : g.getAtoms()) { atoms.add(a); } } return atoms.toArray(new Atom[atoms.size()]); }
for (Atom atom : group.getAtoms()) { Set<Group> set = getGroupsWithinShell(structure, atom, excludeGroups, distance, includeWater);
@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; }
/** * Transforms a group object, given a Matrix4d (i.e. the vecmath library * double-precision 4x4 rotation+translation matrix). The transformation * Matrix must be a post-multiplication Matrix. * * @param group * @param m */ public static final void transform(Group group, Matrix4d m) { for (Atom atom : group.getAtoms()) { transform(atom, m); } for (Group altG : group.getAltLocs()) { transform(altG, m); } }
/** * Translates a group object, given a Vector3d (i.e. the vecmath library * double-precision 3-d vector) * * @param group * @param v */ public static final void translate (Group group, Vector3d v) { for (Atom atom : group.getAtoms()) { translate(atom,v); } for (Group altG : group.getAltLocs()) { translate(altG, v); } }
/** * Returns and array of all non-Hydrogen atoms in the given Chain, * optionally including HET atoms or not Waters are not included. * * @param c * @param hetAtoms * if true HET atoms are included in array, if false they are not * @return */ public static final Atom[] getAllNonHAtomArray(Chain c, boolean hetAtoms) { List<Atom> atoms = new ArrayList<Atom>(); for (Group g : c.getAtomGroups()) { if (g.isWater()) continue; for (Atom a : g.getAtoms()) { if (a.getElement() == Element.H) continue; if (!hetAtoms && g.getType().equals(GroupType.HETATM)) continue; atoms.add(a); } } return atoms.toArray(new Atom[atoms.size()]); }
private void trimBondLists() { for (int modelInd=0; modelInd<structure.nrModels(); modelInd++){ for (Chain chain : structure.getChains(modelInd)) { for (Group group : chain.getAtomGroups()) { for (Atom atom : group.getAtoms()) { if (atom.getBonds()!=null && atom.getBonds().size() > 0) { ((ArrayList<Bond>) atom.getBonds()).trimToSize(); } } } } } }
/** * Returns and array of all non-Hydrogen atoms coordinates in the given Chain, * optionally including HET atoms or not Waters are not included. * * @param c * @param hetAtoms * if true HET atoms are included in array, if false they are not * @return */ public static final Point3d[] getAllNonHCoordsArray(Chain c, boolean hetAtoms) { List<Point3d> atoms = new ArrayList<Point3d>(); for (Group g : c.getAtomGroups()) { if (g.isWater()) continue; for (Atom a : g.getAtoms()) { if (a.getElement() == Element.H) continue; if (!hetAtoms && g.getType().equals(GroupType.HETATM)) continue; atoms.add(a.getCoordsAsPoint3d()); } } return atoms.toArray(new Point3d[atoms.size()]); }
/** only shift CA positions. * */ public static void shiftCA2(AFPChain afpChain, Atom[] ca2, Matrix m, Atom shift, Group[] twistedGroups) { int i = -1; for (Atom a: ca2){ i++; Group g = a.getGroup(); Calc.rotate(g,m); Calc.shift(g, shift); if (g.hasAltLoc()){ for (Group alt: g.getAltLocs()){ for (Atom alta : alt.getAtoms()){ if ( g.getAtoms().contains(alta)) continue; Calc.rotate(alta,m); Calc.shift(alta,shift); } } } twistedGroups[i]=g; } }
/** * Prints the connections in PDB style * * Rewritten since 5.0 to use {@link Bond}s * Will produce strictly one CONECT record per bond (won't group several bonds in one line) */ private String printPDBConnections(){ StringBuilder str = new StringBuilder(); for (Chain c:structure.getChains()) { for (Group g:c.getAtomGroups()) { for (Atom a:g.getAtoms()) { if (a.getBonds()!=null) { for (Bond b:a.getBonds()) { //7890123456789012345678901234567890123456789012345678901234567890 str.append(String.format("CONECT%5d%5d "+newline, b.getAtomA().getPDBserial(), b.getAtomB().getPDBserial())); } } } } } return str.toString(); }
public static Set<Group> getGroupsWithinShell(Structure structure, Atom atom, Set<ResidueNumber> excludeResidues, double distance, boolean includeWater) { // square the distance to use as a comparison against getDistanceFast // which returns the square of a distance. distance = distance * distance; Set<Group> returnSet = new LinkedHashSet<Group>(); for (Chain chain : structure.getChains()) { groupLoop: for (Group chainGroup : chain.getAtomGroups()) { if (!includeWater && chainGroup.isWater()) continue; for (ResidueNumber rn : excludeResidues) { if (rn.equals(chainGroup.getResidueNumber())) continue groupLoop; } for (Atom atomB : chainGroup.getAtoms()) { // use getDistanceFast as we are doing a lot of comparisons double dist = Calc.getDistanceFast(atom, atomB); if (dist <= distance) { returnSet.add(chainGroup); break; } } } } return returnSet; }
List<Atom> groupAtoms = g.getAtoms(); if( ! grid.hasAnyContact(Calc.atomsToPoints(groupAtoms))) { continue;
/** * Cleans up the structure's alternate location (altloc) groups. All alternate location groups should have all atoms (except * in the case of microheterogenity) or when a deuterium exists. * Ensure that all the alt loc groups have all the atoms in the main group. * @param structure The Structure to be cleaned up */ public static void cleanUpAltLocs(Structure structure) { for (int i =0; i< structure.nrModels() ; i++){ for (Chain chain : structure.getModel(i)) { for (Group group : chain.getAtomGroups()) { for (Group altLocGroup : group.getAltLocs()) { for ( Atom groupAtom : group.getAtoms()) { // If this alt loc doesn't have this atom if (! altLocGroup.hasAtom(groupAtom.getName())) { // Fix for microheterogenity if (altLocGroup.getPDBName().equals(group.getPDBName())) { // If it's a Hydrogen then we check for it's Deuterated brother if(!hasDeuteratedEquiv(groupAtom, altLocGroup)){ altLocGroup.addAtom(groupAtom); } } } } } } } } }
List<Atom> atoms = g.getAtoms();