Charles Musgui wrote:

> Hello,
>
> I would like to know how I can interact with a protein model loaded 
> within JMol. To be more precise, here is what I'd like to do, directly 
> using the JMol API:
> 1. get the protein model, then get the Chain IDs contained in the 
> model (I suppose here I handle a protein 3D structure)
> 2. get a particular Chain using its ID,
> 3. given the chain, get its protein sequence
>
> I've tried to understand the JMol API and I've found the package 
> "org.jmol.modelsetbio", but I've failed to figure out how to retrieve 
> a "BioModel" out of the  JMolViewer.
>
Not all objects are public. Realize that in general multiple models may 
be loaded, so even if you aren't doing that, getting the chain ids 
themselves is a bit tricky. Still, a lot of the objects are public. The 
primary public interface is via Viewer. you can refer to it as a 
JmolViewer or Viewer. If via JmolViewer, then you are restricted to the 
JmolViewer interface, which gives you several useful methods. If you  
refer to it as Viewer, then you have many more public methods, BUT 
realize that future Jmol development may modify the signatures of these 
non-JmolViewer methods at a developer's whim. So...

JmolViewer methods:

  abstract public int getModelCount();
  abstract public int getDisplayModelIndex();
  abstract public int getAtomCount();
  abstract public int getBondCount();
  abstract public int getGroupCount(); //for all models; DOES include 
water "chain"
  abstract public int getChainCount();
  abstract public int getPolymerCount();
  abstract public int getAtomCountInModel(int modelIndex);
  abstract public int getBondCountInModel(int modelIndex);
  abstract public int getGroupCountInModel(int modelIndex);
  abstract public int getChainCountInModel(int modelIindex); //does NOT 
include the water "chain"
  abstract public int getPolymerCountInModel(int modelIndex);

So there you can get the number of chains in one or more models.


Viewer methods:

  public ModelSet getModelSet() {
    return modelSet;
  }

  public Hashtable getAllChainInfo(Object atomExpression) {
    return modelSet.getAllChainInfo(getAtomBitSet(atomExpression));
  }


This last should be all you need. It delivers information from methods 
in modelset.ModelCollection:

  public Hashtable getAllChainInfo(BitSet bs) {
    Hashtable finalInfo = new Hashtable();
    Vector modelVector = new Vector();
    for (int i = 0; i < modelCount; ++i) {
      Hashtable modelInfo = new Hashtable();
      Vector info = getChainInfo(i, bs);
      if (info.size() > 0) {
        modelInfo.put("modelIndex",new Integer(i));
        modelInfo.put("chains",info);
        modelVector.addElement(modelInfo);
      }
    }
    finalInfo.put("models",modelVector);
    return finalInfo;
  }

  private Vector getChainInfo(int modelIndex, BitSet bs) {
    Model model = models[modelIndex];
    int nChains = model.getChainCount(true);
    Vector infoChains = new Vector();   
    for(int i = 0; i < nChains; i++) {
      Chain chain = model.getChain(i);
      Vector infoChain = new Vector();
      int nGroups = chain.getGroupCount();
      Hashtable arrayName = new Hashtable();
      for (int igroup = 0; igroup < nGroups; igroup++) {
        Group group = chain.getGroup(igroup);
        if (! bs.get(group.firstAtomIndex))
          continue;
        Hashtable infoGroup = new Hashtable();
        infoGroup.put("groupIndex", new Integer(igroup));
        infoGroup.put("groupID", new Short(group.getGroupID()));
        infoGroup.put("seqCode", group.getSeqcodeString());
        infoGroup.put("_apt1", new Integer(group.firstAtomIndex));
        infoGroup.put("_apt2", new Integer(group.lastAtomIndex));
        infoGroup.put("atomInfo1", getAtomInfo(group.firstAtomIndex));
        infoGroup.put("atomInfo2", getAtomInfo(group.lastAtomIndex));
        infoGroup.put("visibilityFlags", new 
Integer(group.shapeVisibilityFlags));
        infoChain.addElement(infoGroup);
      }
      if (! infoChain.isEmpty()) {
        arrayName.put("residues",infoChain);
        infoChains.addElement(arrayName);
      }
    }
    return infoChains;
  } 
 

That covers just about anything you would want to get in relation to chains.


 





> Thanks for your help,
> Charles
>
>------------------------------------------------------------------------
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by: Microsoft
>Defy all challenges. Microsoft(R) Visual Studio 2008.
>http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Jmol-developers mailing list
>Jmol-developers@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/jmol-developers
>  
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get. 

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to