public static final String convertAtomsToSeq(Atom[] atoms) { StringBuilder buf = new StringBuilder(); Group prevGroup = null; for (Atom a : atoms) { Group g = a.getGroup(); if (prevGroup != null) { if (prevGroup.equals(g)) { // we add each group only once. continue; } } String code3 = g.getPDBName(); Character code1 = get1LetterCodeAmino(code3); if (code1 == null) code1 = UNKNOWN_GROUP_LABEL; buf.append(code1); prevGroup = g; } return buf.toString(); }
/** calculates scores for this alignment ( %id ) * @param ca1 set of Atoms for molecule 1 * @param ca2 set of Atoms for molecule 2 */ public void calcScores(Atom[] ca1, Atom[] ca2){ eqr0 = idx1.length; gaps0 = count_gaps(idx1,idx2); percId = 0; // calc the % id for (int i=0 ; i< idx1.length; i++){ Atom a1 = ca1[idx1[i]]; Atom a2 = ca2[idx2[i]]; Group g1 = a1.getGroup(); Group g2 = a2.getGroup(); if ( g1.getPDBName().equals(g2.getPDBName())){ percId++; } } }
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()]); }
/** * Get the protein sequence of the Subunit as String. * * @return protein sequence String */ public String getProteinSequenceString() { if (sequence != null) return sequence.toString(); StringBuilder builder = new StringBuilder(); for (Atom a : reprAtoms) // This method preferred over getChemComp.getOneLetterCode because // it returns always X for Unknown residues builder.append(StructureTools.get1LetterCode(a.getGroup() .getPDBName())); return builder.toString(); }
private Structure getParentStructure() { Atom[] firstMol = this.molecules.getFirst(); if (firstMol.length==0) { logger.warn("No atoms found in first molecule, can't get parent Structure"); return null; } return firstMol[0].getGroup().getChain().getStructure(); }
/** * Finds the parent chains by looking up the references of first atom of each side of this interface * @return */ public Pair<Chain> getParentChains() { Atom[] firstMol = this.molecules.getFirst(); Atom[] secondMol = this.molecules.getSecond(); if (firstMol.length==0 || secondMol.length==0) { logger.warn("No atoms found in first or second molecule, can't get parent Chains"); return null; } return new Pair<Chain>(firstMol[0].getGroup().getChain(), secondMol[0].getGroup().getChain()); }
/** * Copies the first length atoms from the input array * @param ca The array to copy * @param length the number of atoms to copy * @param clone If true, preform a deep copy, cloning the underlying Groups * @return An array with the first length items of ca, possibly cloning the Atoms. * @throws StructureException */ private Atom[] getAtoms(Atom[] ca, int length, boolean clone) throws StructureException{ List<Atom> atoms = new ArrayList<Atom>(); for ( int i = 0 ; i < length ; i++){ Atom a; if ( clone ){ Group g = (Group)ca[i].getGroup().clone(); a = g.getAtom(ca[i].getName()); } else { a = ca[i]; } 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()]); }
public static void toPDB(Atom a, StringBuffer str) { toPDB(a,str,a.getGroup().getChain().getName()); }
/** * Returns the corresponding AtomContact or null if no contact exists between the 2 given atoms * @param atom1 * @param atom2 * @return */ public AtomContact getContact(Atom atom1, Atom atom2) { return contacts.get(new Pair<AtomIdentifier>( new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()), new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) )); }
private static CharSequence getPDBPos(Atom atom) { Group g = atom.getGroup(); if ( g!= null){ Chain c = g.getChain(); if (c != null){ return g.getResidueNumber().toString()+":" + c.getName() ; //return g.getPDBCode()+":" + c.getName() + "." + getOneLetter(g) ; } } return "!"; }
private void atoms2groups(AtomContactSet atomContacts) { for (AtomContact atomContact:atomContacts) { Pair<Atom> atomPair = atomContact.getPair(); Group iResidue = atomPair.getFirst().getGroup(); Group jResidue = atomPair.getSecond().getGroup(); // we skip the self-residue contacts if (iResidue.equals(jResidue)) continue; Pair<Group> residuePair = new Pair<Group> (iResidue, jResidue); Pair<ResidueIdentifier> pair = new Pair<ResidueIdentifier>(new ResidueIdentifier(iResidue), new ResidueIdentifier(jResidue)); if (!contacts.containsKey(pair)) { GroupContact groupContact = new GroupContact(); groupContact.setPair(residuePair); groupContact.addAtomContact(atomContact); contacts.put(pair, groupContact); } else { GroupContact groupContact = contacts.get(pair); groupContact.addAtomContact(atomContact); } } }
private void rot_mol(Atom[] caA, Atom[] caB, int nse2, Matrix m , Atom shift) throws StructureException{ for(int l=0; l<nse2; l++) { Atom a = caA[l]; Group g = (Group)a.getGroup().clone(); //Group g = (Group)a.getParent(); Calc.rotate( g, m); Calc.shift( g, shift); caB[l] = g.getAtom(a.getName()); } }
private void rot_mol(Atom[] caA, Atom[] caB, int nse2, Matrix m , Atom shift) throws StructureException{ for(int l=0; l<nse2; l++) { Atom a = caA[l]; Group g = (Group)a.getGroup().clone(); //Group g = (Group)a.getParent(); Calc.rotate( g, m); Calc.shift( g, shift); caB[l] = g.getAtom(a.getName()); } }
/** * * @param atom a {@link Atom} in structure. * @param isParentAminoAcid true if the containing group is an amino acid. * @return the {@link StructureAtom} of the atom. */ public static StructureAtom getStructureAtom(Atom atom, boolean isParentAminoAcid) { Group g = atom.getGroup(); String chainId = g.getChainId(); StructureGroup strucGroup = getStructureGroup(g, isParentAminoAcid); strucGroup.setChainId(chainId); return new StructureAtom(strucGroup, atom.getName()); }
public static void printXMLEQRInferPositions(PrettyXMLWriter xml, AFPChain afpChain, int bk, Atom[] ca1, Atom[] ca2) throws IOException{ int[] optLen = afpChain.getOptLen(); if ( optLen == null) return; int[][][] optAln = afpChain.getOptAln(); for ( int pos=0;pos< optLen[bk];pos++){ int pos1 = optAln[bk][0][pos]; int pos2 = optAln[bk][1][pos]; xml.openTag("eqr"); xml.attribute("eqrNr", String.valueOf(pos)); xml.attribute("pdbres1",ca1[pos1].getGroup().getResidueNumber().toString()); xml.attribute("chain1", ca1[pos1].getGroup().getChain().getName()); xml.attribute("pdbres2",ca2[pos2].getGroup().getResidueNumber().toString()); xml.attribute("chain2", ca2[pos2].getGroup().getChain().getName()); xml.closeTag("eqr"); //System.out.println("aligned position: " + pos1 + ":" + pos2 + //" pdbresnum " + ca1[pos1].getGroup().getResidueNumber().toString() + " " + //ca1[pos1].getParent().getPDBName()+":" + //ca2[pos2].getGroup().getResidueNumber().toString() + " " + ca2[pos2].getParent().getPDBName()); } }
private void setAtoms(Structure s, SequenceScalePanel panel){ if ( structurePairAligner == null){ System.err.println("StructurePairAligner has not been set"); return; } Atom[] ca1 = structurePairAligner.getAlignmentAtoms(s); Chain c = new ChainImpl(); c.setChainID("1"); for (Atom atom : ca1) { Group g = atom.getGroup(); Chain parentChain = g.getChain(); c.addGroup(g); // hack for Jmol? g.setChain(parentChain); } panel.setChain(c); }
/** * Create and set a new structure from a given atom array. * @param atoms */ public void setAtoms(Atom[] atoms){ Structure s = new StructureImpl(); Chain c = new ChainImpl(); c.setId("A"); for (Atom a: atoms){ c.addGroup(a.getGroup()); } s.addChain(c); setStructure(s); }
private Pair<AtomIdentifier> getAtomIdPairFromContact(AtomContact contact) { Pair<AtomIdentifier> pair = new Pair<AtomIdentifier>( new AtomIdentifier(contact.getPair().getFirst().getPDBserial(),contact.getPair().getFirst().getGroup().getChainId()), new AtomIdentifier(contact.getPair().getSecond().getPDBserial(),contact.getPair().getSecond().getGroup().getChainId())); return pair; }