[Biojava-l] modify structure
Tamas Horvath
hotafin at gmail.com
Fri Dec 2 08:23:04 EST 2005
Just to be more clear:I store the AminoAcides as HashMap<String,Group> where 1 group contains 1AA, and the String is the name of the AA. (I prefer 1 letter code there)
To shift the desired AA in place, I'd match the Cb atomsThen rotate the AA so that the Ca-Cb line would matchThen rotate the AA so that the N-Ca-Cb pane matches (In this case it's equalto the N-Ca line match)
After this, the AA would be roughly in place.
After this there may should be a collision test, but I think that part canbe handeled by the GROMACS package, which I'd ther run anyway to see how themutation effects the structure.
On 12/2/05, Tamas Horvath <hotafin at gmail.com> wrote:>> Thanks for the codes! I've noticed the methods in Calc, but my main> question is the following. Let's say I've got a primitive library of> AminoAcides. They stored as a group, they have all the atoms. When I'm> mutating the chain, I want to keep the backbone atoms in place, so as far as> your mutate method goes it's ok. But now I want to replace the sidechain. In> order to do that, I'd shift and rotate the desired AA in place (Cbs would be> identical and the other backbone atoms as close as possible), and then copy> the sidechain atoms to the mutated AA... (I hope that's clear)>> So do I have to wrap my Group objects to a Chain/Structure object in order> to shift and rotate them?>> I don't really get how the rotation is supposed to work... what is exactly> the matrix it asks for?>> On 12/2/05, Andreas Prlic <ap3 at sanger.ac.uk> wrote:> >> > Hi Tamas!> >> >> > > If I've got a Group , which is an amino acid, and I want to shift it> > > by a 3D vector (or 3 2D vectors), how may I do it?> >> > There is the org.biojava.bio.structure.Calc class that allows to do> > calculations with the structure.> >> > e.g. to shift a structure do:> >> >> > double x = 2.0;> > double y = 0.2;> > double z = 12.3;> >> > Atom vector = new AtomImpl();> > vector.setX(x);> > vector.setY(y);> > vector.setZ(z);> >> > // shift the structure.> > Calc.shift(structure,vector);> >> >> >> > > Similarly, if i want to rotate the same structure, how may I do it?> >> > double[][] matrix = new double[3][3];> >> > matrix[0][0] = 0.1;> > matrix[0][1] = 0.2;> > matrix[0][2] = 0.3;> > matrix[1][0] = 0.4;> > matrix[1][1] = 0.5;> > matrix[1][2] = 0.6;> > matrix[2][0] = 0.7;> > matrix[2][1] = 0.8;> > matrix[2][2] = 0.9;> >> > Calc.rotate(structure,matrix);> >> >> > And here is an example regarding your questions from yesterday,> > how to do mutations. most of the code actually deals with finding the> > right chain and residue.> > I will add the "mutator" class to cvs, so in future doing mutations> > will be a two liner...> >> > Cheers,> > Andreas> >> >> > /*> > * BioJava development code> > *> > * This code may be freely distributed and modified under the> > * terms of the GNU Lesser General Public Licence. This should> > * be distributed with the code. If you do not have a copy,> > * see:> > *> > * http://www.gnu.org/copyleft/lesser.html> > *> > * Copyright for this code is held jointly by the individual> > * authors. These should be listed in @author doc comments.> > *> > * For more information on the BioJava project and its aims,> > * or to join the biojava-l mailing list, visit the home page> > * at:> > *> > * http://www.biojava.org/> > *> > * Created on Nov 30, 2005> > *> > */> >> > import java.io.FileOutputStream;> > import java.io.PrintStream;> > import java.util.ArrayList;> > import java.util.Iterator;> > import java.util.List;> >> > import org.biojava.bio.structure.AminoAcid;> > import org.biojava.bio.structure.AminoAcidImpl;> > import org.biojava.bio.structure.Atom;> > import org.biojava.bio.structure.AtomIterator;> > import org.biojava.bio.structure.Chain;> > import org.biojava.bio.structure.ChainImpl;> > import org.biojava.bio.structure.Group;> > import org.biojava.bio.structure.Structure ;> > import org.biojava.bio.structure.StructureImpl;> > import org.biojava.bio.structure.io.PDBFileReader;> > import org.biojava.bio.structure.io.PDBParseException;> >> >> > public class structureTest {> >> > public structureTest() {> > super();> >> > }> >> > public static void main (String[] args){> > String filename = "/Users/ap3/WORK/PDB/5pti.pdb" ;> > String outputfile = "/Users/ap3/WORK/PDB/mutated.pdb" ;> >> > PDBFileReader pdbreader = new PDBFileReader();> >> > try{> > Structure struc = pdbreader.getStructure(filename);> > System.out.println(struc);> >> >> > String chainId = " ";> > String pdbResnum = "2";> > String newType = "ARG";> >> > // mutate the original structure and create a new one.> > Mutator m = new Mutator();> > Structure newstruc => > m.mutate(struc,chainId,pdbResnum,newType);> >> > FileOutputStream out= new FileOutputStream(outputfile);> > PrintStream p = new PrintStream( out );> >> > p.println (newstruc.toPDB());> >> > p.close();> >> >> > } catch (Exception e) {> > e.printStackTrace();> > }> > }> > }> >> > class Mutator{> > List supportedAtoms;> >> > public Mutator(){> > supportedAtoms = new ArrayList();> > supportedAtoms.add("N");> > supportedAtoms.add("CA");> > supportedAtoms.add ("C");> > supportedAtoms.add("O");> > supportedAtoms.add("CB");> > }> >> > /** creates a new structure which is identical with the original> > one.> > * only one amino acid will be different.> > *> > * @param struc> > * @param chainId> > * @param pdbResnum> > * @param newType> > * @return> > * @throws PDBParseException> > */> > public Structure mutate(Structure struc, String chainId, String> > pdbResnum, String newType)> > throws PDBParseException{> >> >> > // create a container for the new structure> > Structure newstruc = new StructureImpl();> >> > // first we need to find our corresponding chain> >> > // get the chains for model nr. 0> > // if structure is xray there will be only one "model".> > List chains = struc.getChains(0);> >> > // iterate over all chains.> > Iterator iter = chains.iterator();> > while (iter.hasNext()){> > Chain c = (Chain)iter.next();> > if (c.getName().equals(chainId)) {> > // here is our chain!> >> > Chain newchain = new ChainImpl();> > newchain.setName(c.getName());> >> > List groups = c.getGroups();> >> > // now iterate over all groups in this chain.> > // in order to find the amino acid that has this> > pdbRenum.> >> > Iterator giter = groups.iterator();> > while (giter.hasNext()){> > Group g = (Group) giter.next();> > String rnum = g.getPDBCode();> >> > // we only mutate amino acids> > // and ignore hetatoms and nucleotides in this case> > if ( rnum.equals(pdbResnum) &&> > (g.getType().equals("amino"))){> >> > // create the mutated amino acid and add it to> > our new chain> > AminoAcid newgroup => > mutateResidue((AminoAcid)g,newType);> > newchain.addGroup(newgroup);> > }> > else {> > // add the group to the new chain unmodified.> > newchain.addGroup(g);> > }> > }> >> > // add the newly constructed chain to the structure;> > newstruc.addChain(newchain);> > } else {> > // this chain is not requested, add it to the new> > structure unmodified.> > newstruc.addChain(c);> > }> >> > }> > return newstruc;> > }> >> > /** create a new residue which is of the new type.> > * Only the atoms N, Ca, C, O, Cb will be considered.> > * prolines are not mutated...> > * @param oldAmino> > * @param newType> > * @return> > */> > public AminoAcid mutateResidue(AminoAcid oldAmino, String newType)> > throws PDBParseException {> >> > AminoAcid newgroup = new AminoAcidImpl();> >> > newgroup.setPDBCode (oldAmino.getPDBCode());> > newgroup.setPDBName(newType);> >> >> > AtomIterator aiter =new AtomIterator(oldAmino);> > while (aiter.hasNext()){> > Atom a = (Atom)aiter.next();> > if ( supportedAtoms.contains(a.getName())){> > newgroup.addAtom(a);> > }> > }> >> > return newgroup;> >> > }> >> > }> >> > -----------------------------------------------------------------------> >> > Andreas Prlic Wellcome Trust Sanger Institute> > Hinxton, Cambridge CB10 1SA, UK> > +44 (0) 1223 49 6891> >> > _______________________________________________> > Biojava-l mailing list - Biojava-l at biojava.org> > http://biojava.org/mailman/listinfo/biojava-l> >>>
More information about the Biojava-l
mailing list