Author: scooter
Date: 2010-12-30 11:18:28 -0800 (Thu, 30 Dec 2010)
New Revision: 23283

Modified:
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Chimera.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/OpenTask.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/CommandUtils.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraChain.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraModel.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraResidue.java
   
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/Structure.java
Log:
Refactored to support submodels.  Compiles, but not tested


Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Chimera.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Chimera.java 
    2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Chimera.java 
    2010-12-30 19:18:28 UTC (rev 23283)
@@ -72,7 +72,7 @@
   // Chimera process
   static Process chimera;
        static private List<ChimeraModel> models;
-       static private Map<Float,ChimeraModel> modelHash;
+       static private Map<Integer,ChimeraModel> modelHash;
        static private ListenerThreads listener;
        static private CyNetworkView networkView;
        static private ModelNavigatorDialog mnDialog = null;
@@ -81,6 +81,8 @@
        static Chimera staticPointer = null;
        static CyLogger logger;
 
+       static int MAX_SUB_MODELS = 1000;
+
        static public Chimera GetChimeraInstance(CyNetworkView networkView, 
CyLogger logger) {
                if (staticPointer != null) {
                        staticPointer.setNetworkView(networkView);
@@ -97,7 +99,7 @@
         */
   protected Chimera(CyNetworkView networkView, CyLogger logger) {
                models = new ArrayList<ChimeraModel>();
-               modelHash = new HashMap<Float,ChimeraModel>();
+               modelHash = new HashMap<Integer,ChimeraModel>();
                this.networkView = networkView;
                this.logger = logger;
                selectionList = new ArrayList<ChimeraStructuralObject>();
@@ -116,9 +118,10 @@
         * @param model model number
         * @return the corresponding model
         */
-       public ChimeraModel getChimeraModel (Float model) {
-               if (modelHash.containsKey(model))
-                       return modelHash.get(model);
+       public ChimeraModel getChimeraModel (int model, int subModel) {
+               Integer key = makeModelKey(model,subModel);
+               if (modelHash.containsKey(key))
+                       return modelHash.get(key);
                return null;
        }
 
@@ -129,7 +132,7 @@
         * @return the corresponding model
         */
        public ChimeraModel getChimeraModel (int model) {
-               return getChimeraModel(Float.valueOf((float)model));
+               return getChimeraModel(model, 0);
        }
 
        /**
@@ -205,38 +208,52 @@
        public AlignStructuresDialog getAlignDialog() { return this.alDialog; }
 
        /**
-        * Test to see if we currently have a particular model open
+        * Test to see if we currently have a particular model open.
         *
-        * @param modelNumber the model number expressed as an Float object
+        * @param modelNumber the model number expressed as an integer
+        * @param subModelNumber the subModel number expressed as an integer
         */
-       public boolean containsModel(Float modelNumber) {
-               return modelHash.containsKey(modelNumber);
+       public boolean containsModel(int modelNumber, int subModelNumber) {
+               return modelHash.containsKey(makeModelKey(modelNumber, 
subModelNumber));
        }
 
        /**
-        * Test to see if we currently have a particular model open
+        * Test to see if we currently have a particular model open.
         *
-        * @param modelNumber the model number expressed as a float
+        * @param modelNumber the model number expressed as an int
         */
-       public boolean containsModel(float modelNumber) {
-               Float mn = new Float(modelNumber);
-               return modelHash.containsKey(mn);
+       public boolean containsModel(int modelNumber) {
+               return containsModel(modelNumber, 0);
        }
 
        /**
         * Return the ChimeraModel associated with the requested 
         * model number
         *
-        * @param modelNumber the model number expressed as a float
+        * @param modelNumber the model number expressed as an int
+        * @param subModelNumber the subModel number expressed as an int
         * @return the ChimeraModel with a model number of modelNumber
         */
-       public ChimeraModel getModel(float modelNumber) {
-               Float mn = new Float(modelNumber);
-               return (ChimeraModel)modelHash.get(mn);
+       public ChimeraModel getModel(int modelNumber, int subModelNumber) {
+               Integer key = makeModelKey(modelNumber, subModelNumber);
+               if (modelHash.containsKey(key))
+                       return modelHash.get(key);
+               return null;
        }
 
        /**
         * Return the ChimeraModel associated with the requested 
+        * model number
+        *
+        * @param modelNumber the model number expressed as an int
+        * @return the ChimeraModel with a model number of modelNumber
+        */
+       public ChimeraModel getModel(int modelNumber) {
+               return getModel(modelNumber, 0);
+       }
+
+       /**
+        * Return the ChimeraModel associated with the requested 
         * model name
         *
         * @param modelName the model name expressed as a string
@@ -343,7 +360,7 @@
    * @param structure the Structure to open
    */
   public void open(Structure structure) {
-               structure.setModelNumber(Structure.getNextModel());
+               structure.setModelNumber(Structure.getNextModel(), 0);
                if (structure.getType() == 
Structure.StructureType.MODBASE_MODEL)
                        chimeraSend("listen stop models; listen stop selection; 
open "+structure.modelNumber()+" modbase:"+structure.name());
                else if (structure.getType() == Structure.StructureType.SMILES)
@@ -361,7 +378,7 @@
 
                        // Get our properties (default color scheme, etc.)
                        // Make the molecule look decent
-                       chimeraSend("repr stick #"+newModel.getModelNumber());
+                       chimeraSend("repr stick "+newModel.toSpec());
 
                        if (structure.getType() != 
Structure.StructureType.SMILES) {
                                // Create the information we need for the 
navigator
@@ -372,7 +389,7 @@
                        models.add(newModel);
 
                        // Add it to the hash table
-                       modelHash.put(new 
Float(newModel.getModelNumber()),newModel);
+                       
modelHash.put(makeModelKey(newModel.getModelNumber(),newModel.getSubModelNumber()),newModel);
                }
 
                chimeraSend("focus");
@@ -390,15 +407,17 @@
    * @param structure the Structure to close
         */
        public void close(Structure structure) {
-               float model = structure.modelNumber();
-               chimeraSend("listen stop models; listen stop select; close 
#"+model);
-               System.out.println("listen stop models; listen stop select; 
close #"+model);
-               
-               ChimeraModel chimeraModel = (ChimeraModel)modelHash.get(new 
Float(model));
-               if (chimeraModel != null) {
+               int model = structure.modelNumber();
+               int subModel = structure.subModelNumber();
+               Integer modelKey = makeModelKey(model, subModel);
+               if (modelHash.containsKey(modelKey)) {
+                       ChimeraModel chimeraModel = modelHash.get(modelKey);
+                       chimeraSend("listen stop models; listen stop select; 
close "+chimeraModel.toSpec());
                        models.remove(chimeraModel);
-                       modelHash.remove(new Float(model));
+                       modelHash.remove(modelKey);
                        selectionList.remove(chimeraModel);
+               } else {
+                       chimeraSend("listen stop models; listen stop select; 
close #"+model+"."+subModel);
                }
                chimeraSend("listen start models; listen start select");
                return;
@@ -464,7 +483,7 @@
         */
        public void refresh() {
                // Get a new model list
-               HashMap newHash = new HashMap();
+               HashMap<Integer,ChimeraModel> newHash = new 
HashMap<Integer,ChimeraModel>();
 
                // Stop all of our listeners while we try to handle this
                chimeraSend("listen stop select; listen stop models");
@@ -474,14 +493,17 @@
 
                // Match them up -- assume that the model #'s haven't changed
                for (ChimeraModel model: newModelList) {
-                       Float modelNumber = new Float(model.getModelNumber());
                        // Get the color (for our navigator)
                        model.setModelColor(getModelColor(model));
 
+                       // Get our model info
+                       int modelNumber = model.getModelNumber();
+                       int subModelNumber = model.getSubModelNumber();
+
                        // If we already know about this model number, get the 
Structure,
                        // which tells us about the associated CyNode
-                       if (modelHash.containsKey(modelNumber)) {
-                               ChimeraModel oldModel = 
(ChimeraModel)modelHash.get(modelNumber);
+                       if (containsModel(modelNumber, subModelNumber)) {
+                               ChimeraModel oldModel = getModel(modelNumber, 
subModelNumber);
                                Structure s = oldModel.getStructure();
                                if (s.getType() == 
Structure.StructureType.SMILES)
                                        model.setModelName(s.name());
@@ -489,11 +511,11 @@
                        } else {
                                // This will return a new Structure if we don't 
know about it
                                Structure s = 
CyChimera.findStructureForModel(networkView, model.getModelName());
-                               s.setModelNumber(modelNumber);
+                               s.setModelNumber(model.getModelNumber(), 
model.getSubModelNumber());
                                model.setStructure(s);
                        }
 
-                       newHash.put(modelNumber,model);
+                       newHash.put(makeModelKey(model.getModelNumber(), 
model.getSubModelNumber()),model);
 
                        if (model.getStructure() != null && 
model.getStructure().getType() != Structure.StructureType.SMILES) {
                                // Get the residue information
@@ -502,7 +524,7 @@
                }
 
                // Replace the old model list
-               models = (ArrayList)newModelList;
+               models = newModelList;
                modelHash = newHash;
 
                // Restart all of our listeners
@@ -534,31 +556,33 @@
         * and update our list.
         */
        public void updateSelection() {
-               HashMap<Float,ChimeraModel>modelSelHash = new HashMap();
+               HashMap<Integer,ChimeraModel>modelSelHash = new 
HashMap<Integer, ChimeraModel>();
                clearSelectionList();
 
                // Execute the command to get the list of models with selections
                for (String modelLine: commandReply("lists level molecule")) {
                        ChimeraModel chimeraModel = new ChimeraModel(modelLine);
-                       modelSelHash.put(new 
Float(chimeraModel.getModelNumber()), chimeraModel);
+                       Integer modelKey = 
makeModelKey(chimeraModel.getModelNumber(), chimeraModel.getSubModelNumber());
+                       modelSelHash.put(modelKey, chimeraModel);
                }
 
                // Now get the residue-level data
                for (String inputLine: commandReply("lists level residue")) {
                        ChimeraResidue r = new ChimeraResidue(inputLine);
-                       Float modelNumber = new Float(r.getModelNumber());
-                       if (modelSelHash.containsKey(modelNumber)) {
-                               ChimeraModel model = 
(ChimeraModel)modelSelHash.get(modelNumber);
+                       Integer modelKey = makeModelKey(r.getModelNumber(), 
r.getSubModelNumber());
+                       if (modelSelHash.containsKey(modelKey)) {
+                               ChimeraModel model = modelSelHash.get(modelKey);
                                model.addResidue(r);
                        }
                }
 
                // Get the selected objects
                for (ChimeraModel selectedModel: modelSelHash.values()) {
-                       float modelNumber = selectedModel.getModelNumber();
+                       int modelNumber = selectedModel.getModelNumber();
+                       int subModelNumber = selectedModel.getSubModelNumber();
                        // Get the corresponding "real" model
-                       if (containsModel(modelNumber)) {
-                               ChimeraModel dataModel = getModel(modelNumber);
+                       if (containsModel(modelNumber, subModelNumber)) {
+                               ChimeraModel dataModel = getModel(modelNumber, 
subModelNumber);
                                if (dataModel.getResidueCount() == 
selectedModel.getResidueCount() ||
                                    dataModel.getStructure().getType() == 
Structure.StructureType.SMILES) {
                                        // Select the entire model
@@ -635,15 +659,16 @@
        private List<ChimeraModel> getModelInfoList(Structure structure) {
                String name = structure.name();
                int modelNumber = structure.modelNumber();
+               int subModelNumber = structure.subModelNumber();
                List<ChimeraModel>infoList = new ArrayList();
 
-               for (String modelLine: commandReply("listm type molecule spec 
#"+modelNumber)) {
+               for (String modelLine: commandReply("listm type molecule spec 
#"+modelNumber+"."+subModelNumber)) {
                        // System.out.println("ModelList: "+modelLine);
-                       if (modelLine.contains("id #"+modelNumber)) {
+                       if (modelLine.contains("id 
#"+modelNumber+"."+subModelNumber)) {
                                // System.out.println("Found: "+name);
                                // got the right model, now get the model number
                                ChimeraModel chimeraModel = new 
ChimeraModel(structure, modelLine);
-                               
structure.setModelNumber(chimeraModel.getModelNumber());
+                               
structure.setModelNumber(chimeraModel.getModelNumber(), 
chimeraModel.getSubModelNumber());
                                // System.out.println("Identified model as 
"+chimeraModel);
                                infoList.add(chimeraModel);
                        }
@@ -687,14 +712,26 @@
         * 
         */
        private void getResidueInfo(ChimeraModel model) {
-               float modelNumber = model.getModelNumber();
+               int modelNumber = model.getModelNumber();
+               int subModelNumber = model.getSubModelNumber();
 
                // Get the list -- it will be in the reply log
-               for (String inputLine: commandReply ("listr spec 
#"+modelNumber)) {
+               for (String inputLine: commandReply ("listr spec 
#"+modelNumber+"."+subModelNumber)) {
                        ChimeraResidue r = new ChimeraResidue(inputLine);
-                       if (r.getModelNumber() == modelNumber) {
+                       if (r.getModelNumber() == modelNumber || 
r.getSubModelNumber() == subModelNumber) {
                                model.addResidue(r);
                        }
                }
        }
+
+       /**
+        * Create the key to use for forming the model/submodel key into the 
modelHash
+        *
+        * @param model the model number
+        * @param subModel the submodel number
+        * @return the model key as an Integer
+        */
+       private Integer makeModelKey(int model, int subModel) {
+               return new Integer(model*MAX_SUB_MODELS+subModel);
+       }
 }

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/OpenTask.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/OpenTask.java
    2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/OpenTask.java
    2010-12-30 19:18:28 UTC (rev 23283)
@@ -69,7 +69,7 @@
                        for (Structure openStructure: openStructs) {
                                if (structureName.equals(openStructure.name())) 
{
                                        // Map the model numbers
-                                       
structure.setModelNumber(openStructure.modelNumber());
+                                       
structure.setModelNumber(openStructure.modelNumber(), 
openStructure.subModelNumber());
                                        open = true;
                                        break;
                                }

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/CommandUtils.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/CommandUtils.java
       2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/CommandUtils.java
       2010-12-30 19:18:28 UTC (rev 23283)
@@ -98,10 +98,20 @@
                try {
                        if (spec.startsWith("#")) {
                                try {
-                                       float f = 
Float.parseFloat(spec.substring(1));
-                                       m = chimera.getModel(f);
-                                       if (m == null) {
-                                               throw new 
CyCommandException("No open model: "+f);
+                                       int decimalOffset = 
spec.substring(1).indexOf('.');     // Do we have a sub-model?
+                                       if (decimalOffset > 0) {
+                                               int subModelNumber = 
Integer.parseInt(spec.substring(decimalOffset+1));
+                                               int modelNumber = 
Integer.parseInt(spec.substring(1, decimalOffset));
+                                               m = 
chimera.getModel(modelNumber, subModelNumber);
+                                               if (m == null) {
+                                                       throw new 
CyCommandException("No open model: "+modelNumber+"."+subModelNumber);
+                                               }
+                                       } else {
+                                               int modelNumber = 
Integer.parseInt(spec.substring(1));
+                                               m = 
chimera.getModel(modelNumber, 0);
+                                               if (m == null) {
+                                                       throw new 
CyCommandException("No open model: "+modelNumber);
+                                               }
                                        }
                                } catch (NumberFormatException e) {
                                        throw new CyCommandException("Model 
numbers must be numeric");

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraChain.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraChain.java
  2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraChain.java
  2010-12-30 19:18:28 UTC (rev 23283)
@@ -52,9 +52,10 @@
 public class ChimeraChain implements ChimeraStructuralObject {
 
        /**
-        * The model number this chain is a part of
+        * The model/subModel number this chain is a part of
         */
-       private float model;
+       private int modelNumber;
+       private int subModelNumber;
 
        /**
         * A pointer to the model this chain is a part of
@@ -86,10 +87,12 @@
         * Constructor to create a new ChimeraChain
         *
         * @param model the model number this chain is part of
+        * @param subModel      the subModel number this chain is part of
         * @param chainId the chain ID for this chain
         */
-       public ChimeraChain(float model, String chainId) {
-               this.model = model;
+       public ChimeraChain(int model, int subModel, String chainId) {
+               this.modelNumber = model;
+               this.subModelNumber = subModel;
                this.chainId = chainId;
                residueList = new TreeMap();
        }
@@ -185,9 +188,16 @@
         *
         * @return the model number
         */
-       public float getModelNumber() { return model; }
+       public int getModelNumber() { return modelNumber; }
 
        /**
+        * Get the sub-model number for this chain
+        *
+        * @return the sub-model number
+        */
+       public int getSubModelNumber() { return subModelNumber; }
+
+       /**
         * Return a string representation of this chain as follows:
         *      Chain <i>chainId</i> (<i>residue_count</i> residues)
         *
@@ -229,9 +239,9 @@
         */
        public String toSpec() { 
                if (chainId.equals("_")) {
-                       return("#"+model+":."); 
+                       return("#"+modelNumber+"."+subModelNumber+":."); 
                } else {
-                       return("#"+model+":."+chainId); 
+                       
return("#"+modelNumber+"."+subModelNumber+":."+chainId); 
                }               
        }
 

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraModel.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraModel.java
  2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraModel.java
  2010-12-30 19:18:28 UTC (rev 23283)
@@ -91,7 +91,7 @@
         */
        public ChimeraModel (String inputLine) {
                this.name = parseModelName(inputLine);
-               this.identifier = parseModelNumber(inputLine);
+               this.modelNumber = parseModelNumber(inputLine);
                this.chains = new TreeMap();
                this.residues = new TreeMap();
                this.residueMap = new HashMap();
@@ -107,7 +107,7 @@
        public ChimeraModel (Structure structure, String inputLine) {
                this.name = structure.name();
                this.structure = structure;
-               this.identifier = parseModelNumber(inputLine);
+               this.modelNumber = parseModelNumber(inputLine);
                this.chains = new TreeMap();
                this.residues = new TreeMap();
                this.residueMap = new HashMap();
@@ -214,16 +214,30 @@
         *
         * @return integer model number 
         */
-       public float getModelNumber () { return this.identifier; }
+       public int getModelNumber () { return this.modelNumber; }
 
        /**
+        * Get the sub-model number of this model
+        *
+        * @return integer sub-model number 
+        */
+       public int getSubModelNumber () { return this.subModelNumber; }
+
+       /**
         * Set the model number of this model
         *
         * @param modelNumber integer model number 
         */
-       public void setModelNumber (float modelNumber) { this.identifier = 
modelNumber; }
+       public void setModelNumber (int modelNumber) { this.modelNumber = 
modelNumber; }
 
        /**
+        * Set the sub-model number of this model
+        *
+        * @param subModelNumber integer model number 
+        */
+       public void setSubModelNumber (int subModelNumber) { 
this.subModelNumber = subModelNumber; }
+
+       /**
         * Get the ChimeraModel (required for ChimeraStructuralObject interface)
         *
         * @return ChimeraModel
@@ -302,7 +316,7 @@
        public void addResidue(String chainId, ChimeraResidue residue) {
                ChimeraChain chain = null;
                if (!chains.containsKey(chainId)) {
-                       chain = new ChimeraChain(this.identifier, chainId);
+                       chain = new ChimeraChain(this.modelNumber, 
this.subModelNumber, chainId);
                        chain.setChimeraModel(this);
                        chains.put(chainId, chain);
                } else {
@@ -326,32 +340,42 @@
                if (name.length() > 14)
                        displayName = name.substring(0,13)+"...";
                if (getChainCount() > 0) {
-                       return ("Node "+nodeName+" [Model #"+identifier+" 
"+displayName+" ("+getChainCount()+" chains, "+getResidueCount()+" 
residues)]"); 
+                       return ("Node "+nodeName+" [Model "+toSpec()+" 
"+displayName+" ("+getChainCount()+" chains, "+getResidueCount()+" 
residues)]"); 
                } else if (getResidueCount() > 0) {
-                       return ("Node "+nodeName+" [Model #"+identifier+" 
"+displayName+" ("+getResidueCount()+" residues)]"); 
+                       return ("Node "+nodeName+" [Model "+toSpec()+" 
"+displayName+" ("+getResidueCount()+" residues)]"); 
                } else {
-                       return ("Node "+nodeName+" [Model #"+identifier+" 
"+displayName+"]"); 
+                       return ("Node "+nodeName+" [Model "+toSpec()+" 
"+displayName+"]"); 
                }
        }
 
        /**
         * Return the Chimera specification for this model
         */
-       public String toSpec() { return ("#"+identifier); }
+       public String toSpec() { 
+               if (subModelNumber == 0)
+                       return ("#"+modelNumber);
+               return ("#"+modelNumber+"."+subModelNumber);
+       }
 
        /**
         * Parse the model number returned by Chimera and return
-        * the float value
+        * the int value
         */
-       private float parseModelNumber(String inputLine) {
+       private int parseModelNumber(String inputLine) {
                int hash = inputLine.indexOf('#');
                int space = inputLine.indexOf(' ',hash);
+               int decimal = inputLine.substring(hash+1,space).indexOf('.');
                // model number is between hash+1 and space
                try {
-                       Float modelNumber = new 
Float(inputLine.substring(hash+1,space));
-                       return modelNumber.floatValue();
+                       subModelNumber = 0;
+                       if (decimal > 0) {
+                               subModelNumber = 
Integer.parseInt(inputLine.substring(decimal+1, space));
+                               space = decimal;
+                       }
+                       modelNumber = 
Integer.parseInt(inputLine.substring(hash+1, space));
+                       return modelNumber;
                } catch (Exception e) {
-                       
cytoscape.logger.CyLogger.getLogger(ChimeraResidue.class).error("Unexpected 
return from Chimera: "+inputLine);
+                       
cytoscape.logger.CyLogger.getLogger(ChimeraModel.class).error("Unexpected 
return from Chimera: "+inputLine);
                        return -1;
                }
        }

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraResidue.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraResidue.java
        2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/ChimeraResidue.java
        2010-12-30 19:18:28 UTC (rev 23283)
@@ -57,7 +57,8 @@
        private String type;    // Residue type
        private String index;   // Residue index
        private String chainId; // ChainID for this residue
-       private float modelNumber; // model number for this residue
+       private int modelNumber; // model number for this residue
+       private int subModelNumber; // sub-model number for this residue
        private ChimeraModel chimeraModel; // ChimeraModel thie residue is part 
of
        private Object userData; // user data to associate with this residue
        private static HashMap aaNames = null; // a map of amino acid names
@@ -71,10 +72,23 @@
         * @param index the index of the residue
         * @param modelNumber the model number this residue is part of
         */
-       public ChimeraResidue (String type, String index, float modelNumber) {
+       public ChimeraResidue (String type, String index, int modelNumber) {
+               this(type, index, modelNumber, 0);
+       }
+
+       /**
+        * Constructor to create a new ChimeraResidue
+        *
+        * @param type the residue type
+        * @param index the index of the residue
+        * @param modelNumber the model number this residue is part of
+        * @param subModelNumber the sub-model number this residue is part of
+        */
+       public ChimeraResidue (String type, String index, int modelNumber, int 
subModelNumber) {
                this.type = type;
                this.index = index;
                this.modelNumber = modelNumber;
+               this.subModelNumber = subModelNumber;
                if (aaNames == null)
                        initNames();
        }
@@ -89,11 +103,21 @@
 
                String[] split1 = line.split(":"); 
 
+               // TODO: this should be merged with the parse line code in
+               // ChimeraModel
+
                // First half has model number -- get the number
                int numberOffset = split1[0].indexOf('#');
                String model = split1[0].substring(numberOffset+1);
+               int decimalOffset = model.indexOf('.'); // Do we have a 
sub-model?
                try {
-                       this.modelNumber = (new Float(model)).floatValue();
+                       this.subModelNumber = 0;
+                       if (decimalOffset > 0) {
+                               this.subModelNumber = 
Integer.parseInt(model.substring(decimalOffset+1));
+                               this.modelNumber = 
Integer.parseInt(model.substring(0, decimalOffset));
+                       } else {
+                               this.modelNumber = Integer.parseInt(model);
+                       }
                } catch (Exception e) {
                        
cytoscape.logger.CyLogger.getLogger(ChimeraResidue.class).error("Unexpected 
return from Chimera in ChimeraResidue: "+model);
                        this.modelNumber = -1;
@@ -214,9 +238,16 @@
         *
         * @return the model number
         */
-       public float getModelNumber () { return this.modelNumber; }
+       public int getModelNumber () { return this.modelNumber; }
 
        /**
+        * Get the sub-model number for this residue
+        *
+        * @return the sub-model number
+        */
+       public int getSubModelNumber () { return this.subModelNumber; }
+
+       /**
         * Get the model this residue is part of
         *
         * @return the ChimeraModel

Modified: 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/Structure.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/Structure.java 
    2010-12-30 17:51:24 UTC (rev 23282)
+++ 
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/model/Structure.java 
    2010-12-30 19:18:28 UTC (rev 23283)
@@ -48,6 +48,7 @@
        List<String> residueList;
        CyNode cytoscapeNode;
        int modelNumber;
+       int subModelNumber;
        StructureType type;
 
        public enum StructureType {PDB_MODEL, MODBASE_MODEL, SMILES};
@@ -69,6 +70,7 @@
                this.structureName = name;
                this.cytoscapeNode = node;
                this.modelNumber = nextModel;
+               this.subModelNumber = 0;
                this.residueList = null;
                this.type = type;
        }
@@ -97,18 +99,25 @@
        /**
         * Get the modelNumber for this structure
         *
-        * @return the model number as a float
+        * @return the model number as an int
         */
        public int modelNumber() {return this.modelNumber;}
 
        /**
+        * Get the subModelNumber for this structure
+        *
+        * @return the subModel number as an int
+        */
+       public int subModelNumber() {return this.subModelNumber;}
+
+       /**
         * Set the modelNumber for this structure
         *
         * @param number the model number
         */
-       public void setModelNumber (float number) {
-               Float floatNumber = new Float(number);
-               this.modelNumber = floatNumber.intValue();
+       public void setModelNumber (int number, int subNumber) {
+               this.modelNumber = number;
+               this.subModelNumber = subNumber;
                if (this.modelNumber >= nextModel) nextModel = 
this.modelNumber+1;
        }
 

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to