quickfix for applet when opening relative URLs from feature file : https://mantis...
[jalview.git] / src / jalview / io / ModellerDescription.java
index 91f7961..e4483a5 100755 (executable)
@@ -23,45 +23,49 @@ import jalview.datamodel.*;
 public class ModellerDescription
 {
   /**
-   * Translates between a String containing a set of colon-separated values
-   * on a single line, and sequence start/end and other properties.
-   * See PIRFile IO for its use.
+   * Translates between a String containing a set of colon-separated values on a
+   * single line, and sequence start/end and other properties. See PIRFile IO
+   * for its use.
    */
   final String[] seqTypes =
-      {
-      "sequence", "structure", "structureX", "structureN"};
+  { "sequence", "structure", "structureX", "structureN" };
+
   final String[] Fields =
-      {
-      "objectType", "objectId",
-      "startField", "startCode",
-      "endField", "endCode",
-      "description1", "description2",
-      "resolutionField", "tailField"};
+  { "objectType", "objectId", "startField", "startCode", "endField",
+      "endCode", "description1", "description2", "resolutionField",
+      "tailField" };
+
   final int TYPE = 0;
+
   final int LOCALID = 1;
+
   final int START = 2;
+
   final int START_CHAIN = 3;
+
   final int END = 4;
+
   final int END_CHAIN = 5;
+
   final int DESCRIPTION1 = 6;
+
   final int DESCRIPTION2 = 7;
+
   final int RESOLUTION = 8;
+
   final int TAIL = 9;
 
   /**
-   * 0 is free text or empty
-   * 1 is something that parses to an integer, or \@
+   * 0 is free text or empty 1 is something that parses to an integer, or \@
    */
   final int Types[] =
-      {
-      0, 0, 1, 0, 1, 0, 0, 0, 0, 0
-  };
+  { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0 };
+
   final char Padding[] =
-      {
-      ' ', ' ', ' ', '.', ' ', '.', '.', '.', '.', '.'
-  };
+  { ' ', ' ', ' ', '.', ' ', '.', '.', '.', '.', '.' };
 
   java.util.Hashtable fields = new java.util.Hashtable();
+
   ModellerDescription()
   {
     fields.put(Fields[TAIL], "");
@@ -70,7 +74,9 @@ public class ModellerDescription
   class resCode
   {
     Integer val;
+
     String field;
+
     resCode(String f, Integer v)
     {
       val = v;
@@ -88,7 +94,7 @@ public class ModellerDescription
   {
     Integer val = null;
     com.stevesoft.pat.Regex r = new com.stevesoft.pat.Regex(
-        "\\s*((([-0-9]+).?)|FIRST|LAST|@)");
+            "\\s*((([-0-9]+).?)|FIRST|LAST|@)");
 
     if (!r.search(field))
     {
@@ -100,13 +106,12 @@ public class ModellerDescription
       value = r.stringMatched(1);
     }
     // jalview.bin.Cache.log.debug("from '" + field + "' matched '" + value +
-    //                             "'");
+    // "'");
     try
     {
       val = Integer.valueOf(value);
       return new resCode(field, val); // successful numeric extraction
-    }
-    catch (Exception e)
+    } catch (Exception e)
     {
     }
     return new resCode(field, null);
@@ -129,8 +134,7 @@ public class ModellerDescription
         {
           break;
         }
-      }
-      while (++i < seqTypes.length);
+      } while (++i < seqTypes.length);
 
       if (i < seqTypes.length)
       {
@@ -139,7 +143,7 @@ public class ModellerDescription
         i = 1; // continue parsing fields
         while (i < TAIL && st.hasMoreTokens())
         {
-          if ( (field = st.nextToken(":")) != null)
+          if ((field = st.nextToken(":")) != null)
           {
             // validate residue field value
             if (Types[i] == 1)
@@ -151,8 +155,9 @@ public class ModellerDescription
               }
               else
               {
-                //      jalview.bin.Cache.log.debug(
-                //           "Ignoring non-Modeller description: invalid integer-like field '" + field + "'");
+                // jalview.bin.Cache.log.debug(
+                // "Ignoring non-Modeller description: invalid integer-like
+                // field '" + field + "'");
                 type = -1; /* invalid field! - throw the FieldSet away */
               }
               ;
@@ -209,7 +214,9 @@ public class ModellerDescription
 
   /**
    * make a possibly updated modeller field line for the sequence object
-   * @param seq SequenceI
+   * 
+   * @param seq
+   *                SequenceI
    */
   ModellerDescription(SequenceI seq)
   {
@@ -221,7 +228,8 @@ public class ModellerDescription
 
     if (isModellerFieldset())
     {
-      // Set start and end before we update the type (in the case of a synthesized field set)
+      // Set start and end before we update the type (in the case of a
+      // synthesized field set)
       if (getStartNum() != seq.getStart() && getStartCode().val != null)
       {
         setStartCode(seq.getStart());
@@ -237,21 +245,27 @@ public class ModellerDescription
       // synthesize fields
       setStartCode(seq.getStart());
       setEndCode(seq.getEnd());
-      fields.put(Fields[LOCALID], seq.getName()); // this may be overwritten below...
-      // type - decide based on evidence of PDB database references - this also sets the local reference field
+      fields.put(Fields[LOCALID], seq.getName()); // this may be overwritten
+                                                  // below...
+      // type - decide based on evidence of PDB database references - this also
+      // sets the local reference field
       int t = 0; // sequence
-      if (seq.getDatasetSequence() != null &&
-          seq.getDatasetSequence().getDBRef() != null)
+      if (seq.getDatasetSequence() != null
+              && seq.getDatasetSequence().getDBRef() != null)
       {
-        jalview.datamodel.DBRefEntry[] dbr = seq.getDatasetSequence().getDBRef();
+        jalview.datamodel.DBRefEntry[] dbr = seq.getDatasetSequence()
+                .getDBRef();
         int i, j;
         for (i = 0, j = dbr.length; i < j; i++)
         {
           if (dbr[i] != null)
           {
-            // JBPNote PDB dbRefEntry needs properties to propagate onto ModellerField
-            // JBPNote Need to get info from the user about whether the sequence is the one being modelled, or if it is a template.
-            if (dbr[i].getSource().equals(jalview.datamodel.DBRefSource.PDB))
+            // JBPNote PDB dbRefEntry needs properties to propagate onto
+            // ModellerField
+            // JBPNote Need to get info from the user about whether the sequence
+            // is the one being modelled, or if it is a template.
+            if (dbr[i].getSource()
+                    .equals(jalview.datamodel.DBRefSource.PDB))
             {
               fields.put(Fields[LOCALID], dbr[i].getAccessionId());
               t = 2;
@@ -267,6 +281,7 @@ public class ModellerDescription
 
   /**
    * Indicate if fields parsed to a modeller-like colon-separated value line
+   * 
    * @return boolean
    */
   boolean isModellerFieldset()
@@ -299,7 +314,7 @@ public class ModellerDescription
         value = (String) fields.get(Fields[i]);
         if (value != null && value.length() > 0)
         {
-          desc += ( (String) fields.get(Fields[i])) + ":";
+          desc += ((String) fields.get(Fields[i])) + ":";
         }
         else
         {
@@ -361,7 +376,9 @@ public class ModellerDescription
 
   /**
    * returns true if sequence object was modifed with a valid modellerField set
-   * @param newSeq SequenceI
+   * 
+   * @param newSeq
+   *                SequenceI
    * @return boolean
    */
   boolean updateSequenceI(SequenceI newSeq)