Merge branch 'apifix/JAL-1926_JAL-2106' into develop
authorJim Procter <jprocter@issues.jalview.org>
Thu, 21 Jul 2016 12:03:21 +0000 (13:03 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 21 Jul 2016 12:03:21 +0000 (13:03 +0100)
JAL-1919 JAL-2148 regularise use of jalview.datamodel.PDBEntry.Type for PDB/mmCIF file type
JAL-1919 JAL-2148 use new enum jalview.structure.StructureImportSettings.StructureParser

18 files changed:
src/jalview/analysis/AAFrequency.java
src/jalview/analysis/Dna.java
src/jalview/bin/Cache.java
src/jalview/datamodel/DBRefSource.java
src/jalview/ext/jmol/JmolParser.java
src/jalview/gui/Jalview2XML.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/StructureFile.java
src/jalview/structure/StructureImportSettings.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/workers/AlignCalcWorker.java
src/jalview/workers/AnnotationWorker.java
src/jalview/workers/ColumnCounterWorker.java
src/jalview/ws/dbsources/Pdb.java
test/jalview/analysis/DnaTest.java
test/jalview/ext/jmol/JmolParserTest.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/ws/PDBSequenceFetcherTest.java

index 3d61b11..fb49541 100755 (executable)
@@ -624,8 +624,11 @@ public class AAFrequency
       String modalCodon = String.valueOf(CodingUtils
               .decodeCodon(modalCodonEncoded));
       if (sortedCodonCounts.length > 1
-              && sortedCodonCounts[codons.length - 2] == modalCodonEncoded)
+              && sortedCodonCounts[codons.length - 2] == sortedCodonCounts[codons.length - 1])
       {
+        /*
+         * two or more codons share the modal count
+         */
         modalCodon = "+";
       }
       float pid = sortedCodonCounts[sortedCodonCounts.length - 1] * 100
index d1901c3..800cef2 100644 (file)
@@ -852,13 +852,18 @@ public class Dna
     char[] originalSequence = sequence.toCharArray();
     int length = originalSequence.length;
     char[] reversedSequence = new char[length];
-
+    int bases = 0;
     for (int i = 0; i < length; i++)
     {
-      reversedSequence[length - i - 1] = complement ? getComplement(originalSequence[i])
+      char c = complement ? getComplement(originalSequence[i])
               : originalSequence[i];
+      reversedSequence[length - i - 1] = c;
+      if (!Comparison.isGap(c))
+      {
+        bases++;
+      }
     }
-    SequenceI reversed = new Sequence(newName, reversedSequence, 1, length);
+    SequenceI reversed = new Sequence(newName, reversedSequence, 1, bases);
     return reversed;
   }
 
@@ -874,6 +879,10 @@ public class Dna
   {
     char result = c;
     switch (c) {
+    case '-':
+    case '.':
+    case ' ':
+      break;
     case 'a':
       result = 't';
       break;
index 8493dff..6f16a6e 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.bin;
 
+import jalview.datamodel.PDBEntry;
 import jalview.structure.StructureImportSettings;
 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
 import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
@@ -226,11 +227,15 @@ public class Cache
   private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
 
   private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
-
+  
   /**
    * Allowed values are PDB or mmCIF
    */
-  private final static String DEFAULT_STRUCTURE_FORMAT = "PDB";
+  private final static String DEFAULT_STRUCTURE_FORMAT = PDBEntry.Type.MMCIF
+          .toString();
+
+  private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
+          .toString();
 
   /**
    * Initialises the Jalview Application Log
@@ -428,10 +433,12 @@ public class Cache
     System.out
             .println("Jalview Version: " + codeVersion + codeInstallation);
 
-    StructureImportSettings.setCurrentDefaultFormat(jalview.bin.Cache
+    StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
             .getDefault(
             "DEFAULT_STRUCTURE_FORMAT", DEFAULT_STRUCTURE_FORMAT));
-
+    StructureImportSettings
+            .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+                    "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
     StructureImportSettings.setProcessHETATMs(jalview.bin.Cache.getDefault(
             "PROCESS_HETATM", false));
     // jnlpVersion will be null if we're using InstallAnywhere
index cf15ff8..fba9211 100755 (executable)
@@ -57,11 +57,6 @@ public class DBRefSource
   public static String PDB = "PDB";
 
   /**
-   * mmCIF Entry Code
-   */
-  public static String MMCIF = "mmCIF";
-
-  /**
    * EMBL ID
    */
   public static String EMBL = "EMBL";
index 0ce5f9a..0cbeef6 100644 (file)
@@ -22,7 +22,6 @@ package jalview.ext.jmol;
 
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
 import jalview.io.FileParse;
 import jalview.io.StructureFile;
@@ -87,15 +86,6 @@ public class JmolParser extends StructureFile implements JmolStatusListener
   @Override
   public void parse() throws IOException
   {
-    String dataName = getDataName();
-    if (dataName.endsWith(".cif"))
-    {
-      setDbRefType(DBRefSource.MMCIF);
-    }
-    else
-    {
-      setDbRefType(DBRefSource.PDB);
-    }
     setChains(new Vector<PDBChain>());
     Viewer jmolModel = getJmolData();
     jmolModel.openReader(getDataName(), getDataName(), getReader());
index ac85aad..1633a5d 100644 (file)
@@ -898,10 +898,10 @@ public class Jalview2XML
       for (AlignedCodonFrame acf : jac)
       {
         AlcodonFrame alc = new AlcodonFrame();
-        vamsasSet.addAlcodonFrame(alc);
         if (acf.getProtMappings() != null
                 && acf.getProtMappings().length > 0)
         {
+          boolean hasMap = false;
           SequenceI[] dnas = acf.getdnaSeqs();
           jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
           for (int m = 0; m < pmaps.length; m++)
@@ -911,6 +911,11 @@ public class Jalview2XML
             alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
                     false));
             alc.addAlcodMap(alcmap);
+            hasMap = true;
+          }
+          if (hasMap)
+          {
+            vamsasSet.addAlcodonFrame(alc);
           }
         }
         // TODO: delete this ? dead code from 2.8.3->2.9 ?
@@ -2855,8 +2860,8 @@ public class Jalview2XML
                   mapping });
             }
           }
+          al.addCodonFrame(cf);
         }
-        al.addCodonFrame(cf);
       }
     }
 
index fb414f4..2243a5c 100755 (executable)
@@ -26,6 +26,7 @@ import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
+import jalview.datamodel.PDBEntry.Type;
 import jalview.structure.StructureImportSettings;
 import jalview.util.MessageManager;
 
@@ -280,8 +281,9 @@ public class AppletFormatAdapter
       {
         // TODO obtain config value from preference settings.
         // Set value to 'true' to test PDB processing with Jmol: JAL-1213
-        boolean isParseWithJMOL = !StructureImportSettings
-                .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
+        boolean isParseWithJMOL = StructureImportSettings
+                .getDefaultPDBFileParser()
+                .equals(StructureImportSettings.StructureParser.JMOL_PARSER);
         if (isParseWithJMOL)
         {
           StructureImportSettings.addSettings(annotFromStructure,
@@ -299,6 +301,7 @@ public class AppletFormatAdapter
                   localSecondaryStruct, serviceSecondaryStruct, inFile,
                   type);
         }
+        ((StructureFile) alignFile).setDbRefType(format);
       }
       else if (format.equals("mmCIF"))
       {
@@ -306,6 +309,7 @@ public class AppletFormatAdapter
                 localSecondaryStruct, serviceSecondaryStruct);
         alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, inFile, type);
+        ((StructureFile) alignFile).setDbRefType(format);
       }
       else if (format.equals("STH"))
       {
@@ -447,6 +451,7 @@ public class AppletFormatAdapter
           alignFile = new MCview.PDBfile(annotFromStructure,
                   localSecondaryStruct, serviceSecondaryStruct, source);
         }
+        ((StructureFile) alignFile).setDbRefType(Type.PDB);
       }
       else if (format.equals("mmCIF"))
       {
@@ -454,6 +459,7 @@ public class AppletFormatAdapter
                 localSecondaryStruct, serviceSecondaryStruct);
         alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, source);
+        ((StructureFile) alignFile).setDbRefType(Type.MMCIF);
       }
       else if (format.equals("STH"))
       {
index b2e5b23..fc0e207 100644 (file)
@@ -8,6 +8,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
+import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureImportSettings;
 
@@ -25,7 +26,7 @@ public abstract class StructureFile extends AlignFile
 
   private String id;
 
-  private String dbRefType;
+  private PDBEntry.Type dbRefType;
 
   /**
    * set to true to add derived sequence annotations (temp factor read from
@@ -399,13 +400,18 @@ public abstract class StructureFile extends AlignFile
     this.chains = chains;
   }
 
-  public String getDbRefType()
+  public Type getDbRefType()
   {
     return dbRefType;
   }
 
   public void setDbRefType(String dbRefType)
   {
+    this.dbRefType = Type.valueOf(dbRefType);
+  }
+
+  public void setDbRefType(Type dbRefType)
+  {
     this.dbRefType = dbRefType;
   }
 
index ed53425..388ccbd 100644 (file)
@@ -1,6 +1,14 @@
 package jalview.structure;
 
-
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.PDBEntry.Type;
+
+/**
+ * bean holding settings for structure IO. TODO: tests for validation of values
+ * 
+ * @author tcofoegbu
+ *
+ */
 public class StructureImportSettings
 {
   /**
@@ -25,13 +33,23 @@ public class StructureImportSettings
 
   private static boolean processHETATMs = false;
 
-  public enum StructureFormat
+  public enum StructureParser
   {
-    PDB, MMCIF
-  };
+    JMOL_PARSER, JALVIEW_PARSER
+  }
 
-  private static StructureFormat currentDefaultFormat = StructureFormat.PDB;
 
+  /**
+   * Determines the default file format for structure files to be downloaded
+   * from the PDB sequence fetcher. Possible options include: PDB|mmCIF
+   */
+  private static PDBEntry.Type defaultStructureFileFormat = Type.PDB;
+
+  /**
+   * Determines the parser used for parsing PDB format file. Possible options
+   * are : JMolParser|JalveiwParser
+   */
+  private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
   public static void addSettings(boolean addAlignmentAnnotations,
           boolean processSecStr, boolean externalSecStr)
   {
@@ -84,15 +102,16 @@ public class StructureImportSettings
     StructureImportSettings.showSeqFeatures = showSeqFeatures;
   }
 
-  public static String getCurrentDefaultFormat()
+  public static String getDefaultStructureFileFormat()
   {
-    return currentDefaultFormat.toString();
+    return defaultStructureFileFormat.toString();
   }
 
-  public static void setCurrentDefaultFormat(String currentDefaultFormat)
+  public static void setDefaultStructureFileFormat(
+          String defaultStructureFileFormat)
   {
-    StructureImportSettings.currentDefaultFormat = StructureFormat
-            .valueOf(currentDefaultFormat);
+    StructureImportSettings.defaultStructureFileFormat = PDBEntry.Type
+            .valueOf(defaultStructureFileFormat);
   }
 
   public static boolean isProcessHETATMs()
@@ -105,4 +124,21 @@ public class StructureImportSettings
     StructureImportSettings.processHETATMs = processHETATMs;
   }
 
+  public static String getDefaultPDBFileParser()
+  {
+    return defaultPDBFileParser.toString();
+  }
+
+  public static void setDefaultPDBFileParser(
+          StructureParser defaultPDBFileParser)
+  {
+    StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+  }
+
+  public static void setDefaultPDBFileParser(String defaultPDBFileParser)
+  {
+    StructureImportSettings.defaultPDBFileParser = StructureParser
+            .valueOf(defaultPDBFileParser);
+  }
+
 }
index d3df56c..19ebf45 100644 (file)
@@ -844,14 +844,22 @@ public abstract class AlignmentViewport implements AlignViewportI,
             && !al.getCodonFrames().isEmpty())
     {
       /*
-       * fudge - check first mapping is protein-to-nucleotide
+       * fudge - check first for protein-to-nucleotide mappings
        * (we don't want to do this for protein-to-protein)
        */
-      AlignedCodonFrame mapping = al.getCodonFrames().iterator().next();
-      // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
-      MapList[] mapLists = mapping.getdnaToProt();
-      // mapLists can be empty if project load has not finished resolving seqs
-      if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
+      boolean doConsensus = false;
+      for (AlignedCodonFrame mapping : al.getCodonFrames())
+      {
+        // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
+        MapList[] mapLists = mapping.getdnaToProt();
+        // mapLists can be empty if project load has not finished resolving seqs
+        if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
+        {
+          doConsensus = true;
+          break;
+        }
+      }
+      if (doConsensus)
       {
         if (calculator
                 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
@@ -1872,12 +1880,20 @@ public abstract class AlignmentViewport implements AlignViewportI,
               .getCodonFrames();
       if (codonMappings != null && !codonMappings.isEmpty())
       {
-        // fudge: check mappings are not protein-to-protein
-        // TODO: nicer
-        AlignedCodonFrame mapping = codonMappings.iterator().next();
-        MapList[] mapLists = mapping.getdnaToProt();
-        // mapLists can be empty if project load has not finished resolving seqs
-        if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
+        boolean doConsensus = false;
+        for (AlignedCodonFrame mapping : codonMappings)
+        {
+          // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
+          MapList[] mapLists = mapping.getdnaToProt();
+          // mapLists can be empty if project load has not finished resolving
+          // seqs
+          if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
+          {
+            doConsensus = true;
+            break;
+          }
+        }
+        if (doConsensus)
         {
           complementConsensus = new AlignmentAnnotation("cDNA Consensus",
                   "PID for cDNA", new Annotation[1], 0f, 100f,
index 7719c88..771c492 100644 (file)
@@ -26,6 +26,7 @@ import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
 
 import java.util.List;
 
@@ -103,4 +104,33 @@ public abstract class AlignCalcWorker implements AlignCalcWorkerI
     return false;
   }
 
+  /**
+   * Calculate min and max values of annotations and set as graphMin, graphMax
+   * on the AlignmentAnnotation. This is needed because otherwise, well, bad
+   * things happen.
+   * 
+   * @param ann
+   * @param anns
+   */
+  protected void setGraphMinMax(AlignmentAnnotation ann, Annotation[] anns)
+  {
+    // TODO feels like this belongs inside AlignmentAnnotation!
+    float max = Float.MIN_VALUE;
+    float min = Float.MAX_VALUE;
+    boolean set = false;
+    for (Annotation a : anns) {
+      if (a != null) {
+        set = true;
+        float val = a.value;
+        max = Math.max(max, val);
+        min = Math.min(min, val);
+      }
+    }
+    if (set)
+    {
+      ann.graphMin = min;
+      ann.graphMax = max;
+    }
+  }
+
 }
index efe707a..4d81307 100644 (file)
@@ -79,7 +79,7 @@ class AnnotationWorker extends AlignCalcWorker
         return;
       }
 
-      removeAnnotations();
+      // removeAnnotation();
       AlignmentI alignment = alignViewport.getAlignment();
       if (alignment != null)
       {
@@ -89,10 +89,19 @@ class AnnotationWorker extends AlignCalcWorker
                   alignment, new FeatureRenderer(alignViewport));
           for (AlignmentAnnotation ann : anns)
           {
-            ann.showAllColLabels = true;
-            ann.graph = AlignmentAnnotation.BAR_GRAPH;
-            ourAnnots.add(ann);
-            alignment.addAnnotation(ann);
+            AlignmentAnnotation theAnn = alignment.findOrCreateAnnotation(
+                    ann.label, ann.description, false, null, null);
+            theAnn.showAllColLabels = true;
+            theAnn.graph = AlignmentAnnotation.BAR_GRAPH;
+            theAnn.scaleColLabel = true;
+            theAnn.annotations = ann.annotations;
+            setGraphMinMax(theAnn, theAnn.annotations);
+            theAnn.validateRangeAndDisplay();
+            if (!ourAnnots.contains(theAnn))
+            {
+              ourAnnots.add(theAnn);
+            }
+            // alignment.addAnnotation(ann);
           }
         } catch (IndexOutOfBoundsException x)
         {
@@ -114,19 +123,6 @@ class AnnotationWorker extends AlignCalcWorker
       ap.adjustAnnotationHeight();
       ap.paintAlignment(true);
     }
-
-  }
-
-  /**
-   * Remove all our annotations before re-calculating them
-   */
-  void removeAnnotations()
-  {
-    for (AlignmentAnnotation ann : ourAnnots)
-    {
-      alignViewport.getAlignment().deleteAnnotation(ann);
-    }
-    ourAnnots.clear();
   }
 
   @Override
index 5f61525..2f73cb5 100644 (file)
@@ -89,7 +89,6 @@ class ColumnCounterWorker extends AlignCalcWorker
         return;
       }
 
-      removeAnnotation();
       if (alignViewport.getAlignment() != null)
       {
         try
@@ -159,21 +158,29 @@ class ColumnCounterWorker extends AlignCalcWorker
       {
         Color color = ColorUtils.getGraduatedColour(count, 0, Color.cyan,
                 max, Color.blue);
-        anns[i] = new Annotation(String.valueOf(count),
-                String.valueOf(count), '0', count, color);
+        String str = String.valueOf(count);
+        anns[i] = new Annotation(str, str, '0', count, color);
       }
     }
 
     /*
-     * construct the annotation, save it and add it to the displayed alignment
+     * construct or update the annotation
      */
-    AlignmentAnnotation ann = new AlignmentAnnotation(counter.getName(),
-            counter.getDescription(), anns);
+    AlignmentAnnotation ann = alignViewport.getAlignment()
+            .findOrCreateAnnotation(counter.getName(),
+                    counter.getDescription(), false, null,
+                    null);
+    ann.description = counter.getDescription();
     ann.showAllColLabels = true;
     ann.scaleColLabel = true;
     ann.graph = AlignmentAnnotation.BAR_GRAPH;
-    ourAnnots.add(ann);
-    alignViewport.getAlignment().addAnnotation(ann);
+    ann.annotations = anns;
+    setGraphMinMax(ann, anns);
+    ann.validateRangeAndDisplay();
+    if (!ourAnnots.contains(ann))
+    {
+      ourAnnots.add(ann);
+    }
   }
 
   /**
index a06f0c8..fc636c6 100644 (file)
@@ -27,11 +27,11 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
+import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.io.FormatAdapter;
 import jalview.io.PDBFeatureSettings;
 import jalview.structure.StructureImportSettings;
-import jalview.structure.StructureImportSettings.StructureFormat;
 import jalview.util.MessageManager;
 import jalview.ws.ebi.EBIFetchClient;
 
@@ -133,11 +133,11 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String ext = StructureImportSettings.getCurrentDefaultFormat().equals(
-            StructureFormat.MMCIF) ? ".cif" : ".xml";
+    String ext = StructureImportSettings.getDefaultStructureFileFormat()
+            .equals(Type.MMCIF) ? ".cif" : ".xml";
     EBIFetchClient ebi = new EBIFetchClient();
     file = ebi.fetchDataAsFile("pdb:" + id,
-            StructureImportSettings.getCurrentDefaultFormat().toLowerCase(),
+            StructureImportSettings.getDefaultStructureFileFormat().toLowerCase(),
             ext)
             .getAbsolutePath();
     stopQuery();
@@ -150,7 +150,7 @@ public class Pdb extends EbiFileRetrievedProxy
 
       pdbAlignment = new FormatAdapter().readFile(file,
               jalview.io.AppletFormatAdapter.FILE,
-              StructureImportSettings.getCurrentDefaultFormat());
+              StructureImportSettings.getDefaultStructureFileFormat());
       if (pdbAlignment != null)
       {
         List<SequenceI> toremove = new ArrayList<SequenceI>();
index 9a4c357..0142ab5 100644 (file)
@@ -29,6 +29,7 @@ import jalview.datamodel.AlignedCodon;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignViewport;
 import jalview.io.FormatAdapter;
@@ -498,17 +499,44 @@ public class DnaTest
   @Test(groups = "Functional")
   public void testReverseSequence()
   {
-    String seq = "AcGtUrYkMbVdHNX";
+    String seq = "-Ac-GtU--rYkMbVdHNX-";
+    String seqRev = new StringBuilder(seq).reverse().toString();
 
     // reverse:
     SequenceI reversed = Dna.reverseSequence("Seq1", seq, false);
-    assertEquals(new StringBuilder(seq).reverse()
-            .toString(), reversed.getSequenceAsString());
+    assertEquals(1, reversed.getStart());
+    assertEquals(15, reversed.getEnd());
+    assertEquals(20, reversed.getLength());
+    assertEquals(seqRev, reversed.getSequenceAsString());
     assertEquals("Seq1|rev", reversed.getName());
 
     // reverse complement:
     SequenceI revcomp = Dna.reverseSequence("Seq1", seq, true);
-    assertEquals("XNDhBvKmRyAaCgT", revcomp.getSequenceAsString());
+    assertEquals("-XNDhBvKmRy--AaC-gT-", revcomp.getSequenceAsString());
     assertEquals("Seq1|revcomp", revcomp.getName());
   }
+
+  @Test(groups = "Functional")
+  public void testReverseCdna()
+  {
+    String seq = "-Ac-GtU--rYkMbVdHNX-";
+    String seqRev = new StringBuilder(seq).reverse().toString();
+    String seqDs = seq.replaceAll("-", "");
+    String seqDsRev = new StringBuilder(seqDs).reverse().toString();
+
+    SequenceI dna = new Sequence("Seq1", seq);
+    Alignment al = new Alignment(new SequenceI[] {dna});
+    al.createDatasetAlignment();
+    assertEquals(seqDs, al.getSequenceAt(0).getDatasetSequence()
+            .getSequenceAsString());
+
+    ColumnSelection cs = new ColumnSelection();
+    AlignViewportI av = new AlignViewport(al, cs);
+    Dna testee = new Dna(av, new int[] { 0, al.getWidth() - 1 });
+    AlignmentI reversed = testee.reverseCdna(false);
+    assertEquals(1, reversed.getHeight());
+    assertEquals(seqRev, reversed.getSequenceAt(0).getSequenceAsString());
+    assertEquals(seqDsRev, reversed.getSequenceAt(0).getDatasetSequence()
+            .getSequenceAsString());
+  }
 }
index 0627a4a..2ea0b80 100644 (file)
@@ -31,6 +31,7 @@ import jalview.gui.AlignFrame;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.FileLoader;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 
 import java.util.Vector;
 
@@ -89,6 +90,9 @@ public class JmolParserTest
             Boolean.TRUE.toString());
     Cache.applicationProperties.setProperty("ADD_SS_ANN",
             Boolean.TRUE.toString());
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
index 3524a88..e6019aa 100644 (file)
@@ -32,6 +32,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 
 import java.io.File;
 
@@ -66,7 +67,9 @@ public class AnnotatedPDBFileInputTest
     al = af.getViewport().getAlignment();
     pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
             .get(0).getId();
-    StructureImportSettings.setCurrentDefaultFormat("PDB");
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
index 0c810a3..fda0198 100644 (file)
@@ -26,6 +26,7 @@ import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.util.List;
@@ -86,7 +87,9 @@ public class PDBSequenceFetcherTest
   {
     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
-    StructureImportSettings.setCurrentDefaultFormat("PDB");
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
 
     testRetrieveProteinSeqFromPDB();
   }
@@ -96,7 +99,7 @@ public class PDBSequenceFetcherTest
   {
     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
-    StructureImportSettings.setCurrentDefaultFormat("mmCIF");
+    StructureImportSettings.setDefaultStructureFileFormat("mmCIF");
     testRetrieveProteinSeqFromPDB();
   }