refactoring for DBMODList
[jalview.git] / src / jalview / datamodel / Sequence.java
index 0acf701..7549ef5 100755 (executable)
@@ -27,7 +27,6 @@ import jalview.util.Comparison;
 import jalview.util.DBRefUtils;
 import jalview.util.MapList;
 import jalview.util.StringUtils;
-import jalview.ws.params.InvalidArgumentException;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -56,7 +55,7 @@ public class Sequence extends ASequence implements SequenceI
         * @param <T>
         */
   @SuppressWarnings("serial")
-  protected class DBModList<T> extends ArrayList<DBRefEntry> {
+  public class DBModList<T> extends ArrayList<DBRefEntry> {
 
          protected int getModCount() {
                  return modCount;
@@ -66,19 +65,19 @@ public class Sequence extends ASequence implements SequenceI
 
 SequenceI datasetSequence;
 
-  String name;
+  private String name;
 
   private char[] sequence;
 
-  String description;
+  private String description;
 
-  int start;
+  private int start;
 
-  int end;
+  private int end;
 
-  Vector<PDBEntry> pdbIds;
+  private Vector<PDBEntry> pdbIds;
 
-  String vamsasId;
+  private String vamsasId;
 
   private DBModList<DBRefEntry> dbrefs; // controlled access
 
@@ -89,7 +88,7 @@ SequenceI datasetSequence;
    */
   private int refModCount = 0;
 
-  RNA rna;
+  private RNA rna;
   
   /**
    * This annotation is displayed below the alignment but the positions are tied
@@ -97,7 +96,7 @@ SequenceI datasetSequence;
    *
    * TODO: change to List<>
    */
-  Vector<AlignmentAnnotation> annotation;
+  private Vector<AlignmentAnnotation> annotation;
 
   private SequenceFeaturesI sequenceFeatureStore;
 
@@ -724,6 +723,9 @@ SequenceI datasetSequence;
             @Override
             public String getAssemblyId()
             {
+               // DEV NOTE: DBRefEntry is reused here to hold chromosomal locus of a gene sequence. 
+               // source=species, version=assemblyId, accession=chromosome, map = positions.
+               
               return ref.getVersion();
             }
 
@@ -1410,35 +1412,22 @@ SequenceI datasetSequence;
     vamsasId = id;
   }
 
-  @SuppressWarnings("deprecation")
-@Override
-  public void setDBRefs(List<DBRefEntry> newDBrefs) throws InvalidArgumentException
+  @Deprecated
+  @Override
+  public void setDBRefs(DBModList<DBRefEntry> newDBrefs)
   {
     if (dbrefs == null && datasetSequence != null
             && this != datasetSequence)
     {
-      datasetSequence.setDBRefs((DBModList<DBRefEntry>)newDBrefs);
+      datasetSequence.setDBRefs(newDBrefs);
       return;
     }
-    if (newDBrefs != null && !(newDBrefs instanceof DBModList<?>))
-       throw new InvalidArgumentException("DBrefs must have DBModList class");
-
-    dbrefs = (DBModList<DBRefEntry>)newDBrefs;
+    dbrefs = newDBrefs;
     refModCount = 0;
   }
 
   @Override
-  public void getDBRefsFrom(SequenceI seq) {
-         try {
-               setDBRefs(seq.getDBRefs());
-       } catch (InvalidArgumentException e) {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-       }
-  }
-
-  @Override
-  public List<DBRefEntry> getDBRefs()
+  public DBModList<DBRefEntry> getDBRefs()
   {
     if (dbrefs == null && datasetSequence != null
             && this != datasetSequence)
@@ -1945,6 +1934,7 @@ private List<DBRefEntry> primaryRefs;
         primaries.add(ref);
       }
       
+      // version must be not null, as otherwise it will not be a candidate, above
       DBRefUtils.ensurePrimaries(this, primaries);
       return primaries;
     }