Merge branch 'develop' into LibrAlign
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 31 May 2016 15:50:00 +0000 (17:50 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 31 May 2016 15:50:00 +0000 (17:50 +0200)
17 files changed:
.gitattributes
eu.etaxonomy.taxeditor.molecular.lib/.classpath
eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.molecular.lib/build.properties
eu.etaxonomy.taxeditor.molecular.lib/pom.xml
eu.etaxonomy.taxeditor.molecular/.classpath
eu.etaxonomy.taxeditor.molecular/.gitignore
eu.etaxonomy.taxeditor.molecular/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.molecular/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.molecular/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.molecular/plugin.xml
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ShowPherogramHandler.java
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/CDMSequenceMatrixAdapter.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/ExportSingleReadAlignmentWizardPage.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIterator.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.molecular/src/test/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIteratorTest.java [new file with mode: 0644]

index 877a615a022cb9b9e3ca73dbe3410a5cfe62fb2c..b777e5c2d3624bc23e675dc42b58c032d616db92 100644 (file)
@@ -1975,7 +1975,7 @@ src/site/resources/images/taxeditor_transformed.png -text
 src/site/site.xml -text
 
 # The following files will be ignored when merging another
-# branch into this branch in case of merge conflict and 
+# branch into this branch in case of merge conflict and
 # if the 'ours' merge driver is configured.
 # WARNING : This merge driver should NOT be set in development
 #           environments. It is supposed to be used only in CI
@@ -1987,5 +1987,10 @@ src/site/site.xml -text
 **/feature.xml merge=ours
 eu.etaxonomy.taxeditor.cdmlib/.classpath merge=ours
 eu.etaxonomy.taxeditor.cdmlib/build.properties merge=ours
+eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java -text
+eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/CDMSequenceMatrixAdapter.java -text
+eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/ExportSingleReadAlignmentWizardPage.java -text
+eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIterator.java -text
+eu.etaxonomy.taxeditor.molecular/src/test/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIteratorTest.java -text
 eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product merge=ours
 eu.etaxonomy.taxeditor/eu.etaxonomy.taxeditor.product.with.jre merge=ours
index 55f260ddbb441af33d0469daeafab445cd9ceff0..e844dbc108c2fb7d16049b3f337ca5964ecdbb16 100644 (file)
@@ -13,5 +13,7 @@
        <classpathentry exported="true" kind="lib" path="lib/tic-swt-2.0.0-preview-1.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry exported="true" kind="lib" path="lib/jphyloio-core-0-SNAPSHOT.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/owlapi-xmlutils-4.1.4.jar"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
index dc2e423968bdf250058d7b4fe6c003cc0fa3db7b..c16510ab0922047e22a77639f6c5c3033f24e6e4 100644 (file)
@@ -15,6 +15,8 @@ Bundle-ClassPath: .,
  lib/sequencing-1.9.2-SNAPSHOT.jar,
  lib/tic-core-2.0.0-preview-1.jar,
  lib/tic-swt-2.0.0-preview-1.jar
+ lib/jphyloio-core-0-SNAPSHOT.jar,
+ lib/owlapi-xmlutils-4.1.4.jar
 Export-Package: info.bioinfweb.commons,
  info.bioinfweb.commons.appversion,
  info.bioinfweb.commons.beans,
@@ -30,6 +32,37 @@ Export-Package: info.bioinfweb.commons,
  info.bioinfweb.commons.swing.scrollpaneselector,
  info.bioinfweb.commons.swt,
  info.bioinfweb.commons.text,
+ info.bioinfweb.jphyloio,
+ info.bioinfweb.jphyloio.dataadapters,
+ info.bioinfweb.jphyloio.dataadapters.implementations,
+ info.bioinfweb.jphyloio.dataadapters.implementations.readtowriteadapter,
+ info.bioinfweb.jphyloio.dataadapters.implementations.receivers,
+ info.bioinfweb.jphyloio.events,
+ info.bioinfweb.jphyloio.events.meta,
+ info.bioinfweb.jphyloio.events.type,
+ info.bioinfweb.jphyloio.exception,
+ info.bioinfweb.jphyloio.factory,
+ info.bioinfweb.jphyloio.formats,
+ info.bioinfweb.jphyloio.formats.fasta,
+ info.bioinfweb.jphyloio.formats.mega,
+ info.bioinfweb.jphyloio.formats.newick,
+ info.bioinfweb.jphyloio.formats.nexml,
+ info.bioinfweb.jphyloio.formats.nexml.nexmlreceivers,
+ info.bioinfweb.jphyloio.formats.nexus,
+ info.bioinfweb.jphyloio.formats.nexus.blockhandlers,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders.all,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders.characters,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders.sets,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders.taxa,
+ info.bioinfweb.jphyloio.formats.nexus.commandreaders.trees,
+ info.bioinfweb.jphyloio.formats.pde,
+ info.bioinfweb.jphyloio.formats.phylip,
+ info.bioinfweb.jphyloio.formats.phyloxml,
+ info.bioinfweb.jphyloio.formats.text,
+ info.bioinfweb.jphyloio.formats.xml,
+ info.bioinfweb.jphyloio.formats.xtg,
+ info.bioinfweb.jphyloio.tools,
  info.bioinfweb.libralign,
  info.bioinfweb.libralign.actions,
  info.bioinfweb.libralign.alignmentarea,
@@ -160,7 +193,8 @@ Export-Package: info.bioinfweb.commons,
  org.biojavax.ga.util,
  org.biojavax.ontology,
  org.biojavax.utils,
- org.jdesktop.swingx.scrollpaneselector
+ org.jdesktop.swingx.scrollpaneselector,
+ org.semanticweb.owlapi.io
 Bundle-ActivationPolicy: lazy
 Import-Package: javax.swing
 Require-Bundle: org.eclipse.swt
index 6e6ff3a5a11a55365a4beb17e08abfdee150eaaa..15428893d92facf1e4695a3a7fa4199e7d4d0006 100644 (file)
@@ -10,3 +10,5 @@ bin.includes = META-INF/,\
                lib/sequencing-1.9.2-SNAPSHOT.jar,\
                lib/tic-core-2.0.0-preview-1.jar,\
                lib/tic-swt-2.0.0-preview-1.jar
+               lib/jphyloio-core-0-SNAPSHOT.jar,\
+               lib/owlapi-xmlutils-4.1.4.jar
index 26c2e0b4ce2c7f9c3cab2d4008d7a4da06c4e01f..0d785b9260adad88355e62b9fb432a86b85516b5 100644 (file)
@@ -27,7 +27,8 @@
               <includeArtifactIds>libralign-swt, libralign-core,
                 bioinfweb-commons-swt, bioinfweb-commons-core,
                 bioinfweb-commons-bio, bioinfweb-commons-swing,
-                tic-core, libralign-biojava1, core, sequencing, tic-swt</includeArtifactIds>
+                tic-core, libralign-biojava1, core, sequencing, 
+                tic-swt, jphyloio-core, owlapi-xmlutils</includeArtifactIds>
               <outputDirectory>lib</outputDirectory>
               <overWriteReleases>true</overWriteReleases>
               <overWriteSnapshots>true</overWriteSnapshots>
                   <fileset dir="./lib" />
                   <mapper type="regexp" from="(^tic\-.*\-[0-9]-)[0-9.-]+(\.jar)" to="\1SNAPSHOT\2" />
                 </move>
+                <move todir="./lib">
+                  <fileset dir="./lib" />
+                  <mapper type="regexp" from="(^jphyloio\-.*\-[0-9]-)[0-9.-]+(\.jar)" to="\1SNAPSHOT\2" />
+                </move>
+                <move todir="./lib">
+                  <fileset dir="./lib" />
+                  <mapper type="regexp" from="(^owlapi\-.*\-[0-9]-)[0-9.-]+(\.jar)" to="\1SNAPSHOT\2" />
+                </move>
+                <move todir="./lib">
+                  <fileset dir="./lib" />
+                  <mapper type="regexp" from="commons-collections4-4.1.jar" to="commons-collections4-4.1.jar" />
+                </move>
                 <move todir="./lib">
                   <fileset dir="./lib" />
                   <mapper type="regexp" from="(^core\-[0-9]\.[0-9]\.[0-9])(\.jar)" to="\1-SNAPSHOT\2" />
   </build>
 
   <dependencies>
-    <!-- LibrAling -->
+    <!-- JPhyloIO -->
+    <dependency>
+      <groupId>info.bioinfweb.jphyloio</groupId>
+      <artifactId>jphyloio-core</artifactId>
+      <version>0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>info.bioinfweb.thirdparty.owlapi</groupId>
+      <artifactId>owlapi-xmlutils</artifactId>
+      <version>4.1.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-collections4</artifactId>
+      <version>4.1</version>
+    </dependency>
+    <!-- LibrAlign -->
     <dependency>
       <groupId>info.bioinfweb.libralign</groupId>
       <artifactId>libralign-core</artifactId>
       <artifactId>libralign-biojava1</artifactId>
       <version>0.4.0-preview-1</version>
     </dependency>
-    <!-- commons -->
+    <!-- bioinfweb.commons -->
     <dependency>
       <groupId>info.bioinfweb.commons.java</groupId>
       <artifactId>bioinfweb-commons-swt</artifactId>
       <artifactId>bioinfweb-commons-swing</artifactId>
       <version>2.0.0-preview-1</version>
     </dependency>
-    <!-- tic -->
+    <!-- TIC -->
     <dependency>
       <groupId>info.bioinfweb.tic</groupId>
       <artifactId>tic-core</artifactId>
       <artifactId>tic-swt</artifactId>
       <version>2.0.0-preview-1</version>
     </dependency>
-    <!-- biojava -->
+    <!-- BioJava -->
     <dependency>
       <groupId>org.biojava</groupId>
       <artifactId>core</artifactId>
       <name>bioinfweb repository</name>
       <url>http://bioinfweb.info/MavenRepository/</url>
     </repository>
+    <!-- <repository>
+      <id>central-maven-repo</id>
+      <name>Maven Central</name>
+      <url>http://central.maven.org/maven2/</url>
+    </repository> -->
   </repositories>
-  
 </project> 
 
index 60dea2f68d1f381ff10da83942a19d76d08ab4e8..6bca977bed3b6d2bc7f202c8a811de4878f0c42b 100644 (file)
@@ -3,5 +3,6 @@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+       <classpathentry kind="src" path="src/test/java"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
index e6066b230568e29e52c4935812bcdf841f8a311b..29eb2f8cf13938350b6fb67ad0869eddce05a473 100644 (file)
@@ -1,2 +1,50 @@
 /target
 .settings/
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/.project
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/integration-test.log
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/target
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/.directory
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/hibernate.log
+!src/main/java/eu/etaxonomy/taxeditor/molecular/io/.settings
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/.project
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/integration-test.log
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/target
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/.directory
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/hibernate.log
+!src/test/java/eu/etaxonomy/taxeditor/molecular/io/.settings
+!src/test/java/eu/etaxonomy/taxeditor/molecular/.project
+!src/test/java/eu/etaxonomy/taxeditor/molecular/integration-test.log
+!src/test/java/eu/etaxonomy/taxeditor/molecular/target
+!src/test/java/eu/etaxonomy/taxeditor/molecular/.directory
+!src/test/java/eu/etaxonomy/taxeditor/molecular/hibernate.log
+!src/test/java/eu/etaxonomy/taxeditor/molecular/.settings
+!src/test/java/eu/etaxonomy/taxeditor/.project
+!src/test/java/eu/etaxonomy/taxeditor/integration-test.log
+!src/test/java/eu/etaxonomy/taxeditor/target
+!src/test/java/eu/etaxonomy/taxeditor/.directory
+!src/test/java/eu/etaxonomy/taxeditor/hibernate.log
+!src/test/java/eu/etaxonomy/taxeditor/.settings
+!src/test/java/eu/etaxonomy/.project
+!src/test/java/eu/etaxonomy/integration-test.log
+!src/test/java/eu/etaxonomy/target
+!src/test/java/eu/etaxonomy/.directory
+!src/test/java/eu/etaxonomy/hibernate.log
+!src/test/java/eu/etaxonomy/.settings
+!src/test/java/eu/.project
+!src/test/java/eu/integration-test.log
+!src/test/java/eu/target
+!src/test/java/eu/.directory
+!src/test/java/eu/hibernate.log
+!src/test/java/eu/.settings
+!src/test/java/.project
+!src/test/java/integration-test.log
+!src/test/java/target
+!src/test/java/.directory
+!src/test/java/hibernate.log
+!src/test/java/.settings
+!src/test/.project
+!src/test/integration-test.log
+!src/test/target
+!src/test/.directory
+!src/test/hibernate.log
+!src/test/.settings
index 98f52d374d5676d300940a0538be145b5ad6a216..8afdbe3f26faf0d4367374896572f7fee7a4f73f 100644 (file)
@@ -18,4 +18,5 @@ Bundle-ActivationPolicy: lazy
 Bundle-Vendor: EDIT
 Export-Package: eu.etaxonomy.taxeditor.molecular,
  eu.etaxonomy.taxeditor.molecular.editor,
- eu.etaxonomy.taxeditor.molecular.handler
+ eu.etaxonomy.taxeditor.molecular.handler,
+ eu.etaxonomy.taxeditor.molecular.io
index 06f7cf3213dc21d85dd4dd75ff3464be06fb1563..685f5ce7b010fff78f2fb936418a41134de3dab8 100644 (file)
@@ -3,6 +3,7 @@ editor.ALIGNMENT_EDITOR = Alignment Editor
 view.PHEROGRAM_VIEW = Pherogram View
 command.EDIT_SEQUENCE = Edit Sequence
 command.name.SHOW_PHEROGRAM = Show Pherogram
+command.name.EXPORT_SEQUENCE_TO_FILE = Export to alignment file
 command.name.CUT_PHEROGRAM_LEFT = Cut pherogram left
 command.name.CUT_PHEROGRAM_RIGHT = Cut pherogram right
 command.name.REVERSE_COMPLEMENT_SELECTED_ROWS = Reverse complement selected rows
@@ -18,4 +19,5 @@ command.TOGGLE_INSERT_OVERWRITE = Toggle insert/overwrite
 menu.ALIGNMENT_EDITOR = Alignment Editor
 menu.label.PHEROGRAM_VIEW = Pherogram View
 command.label.EDIT_SEQUENCE = Edit Sequence
+command.label.EXPORT_SEQUENCE_TO_FILE = Export to alignment file
 command.label.SHOW_PHEROGRAM = Show Pherogram
\ No newline at end of file
index 59036928e0bf55b02f84a480b49a42a582881a3f..2fee24384be8a2864f0ab084b78bd0662a48f0ba 100644 (file)
@@ -3,6 +3,7 @@ editor.ALIGNMENT_EDITOR = Alignment Editor
 view.PHEROGRAM_VIEW = PherogramView
 command.EDIT_SEQUENCE = Edit Sequence
 command.name.SHOW_PHEROGRAM = Show Pherogram
+command.name.EXPORT_SEQUENCE_TO_FILE = Alignmentdatei exportieren
 command.name.CUT_PHEROGRAM_LEFT = Cut pherogram left
 command.name.CUT_PHEROGRAM_RIGHT = Cut pherogram right
 command.name.REVERSE_COMPLEMENT_SELECTED_ROWS = Reverse complement selected rows
@@ -18,4 +19,5 @@ command.TOGGLE_INSERT_OVERWRITE = Toggle insert/overwrite
 menu.ALIGNMENT_EDITOR = Alignment Editor
 menu.label.PHEROGRAM_VIEW = Pherogram View
 command.label.EDIT_SEQUENCE = Edit Sequence
+command.label.EXPORT_SEQUENCE_TO_FILE = Alignmentdatei exportieren
 command.label.SHOW_PHEROGRAM = Show Pherogram
\ No newline at end of file
index 78b734fd1ad72db0d93c26f003d3331af3159af4..7df2be1afbbc52fb9c3a097839186d5dbee532e1 100644 (file)
                id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"
                name="%command.name.TOGGLE_LEFT_RIGHT_INSERTION">
          </command>
+         <command
+               defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler"
+               id="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
+               name="%command.name.EXPORT_SEQUENCE_TO_FILE">
+         </command>
       </extension>
       <extension
             point="org.eclipse.ui.menus">
                   </reference>
                </visibleWhen>
             </command>
+            <command
+                  commandId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
+                  label="%command.label.EXPORT_SEQUENCE_TO_FILE"
+                  style="push">
+               <visibleWhen
+                     checkEnabled="true">
+                  <reference
+                        definitionId="isSequence">
+                  </reference>
+               </visibleWhen>
+            </command>
             <command
                   commandId="eu.etaxonomy.taxeditor.molecular.showPherogram"
                   label="%command.label.SHOW_PHEROGRAM"
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
new file mode 100644 (file)
index 0000000..4ccb4d6
--- /dev/null
@@ -0,0 +1,79 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.molecular.handler;\r
+\r
+\r
+import info.bioinfweb.jphyloio.JPhyloIOEventWriter;\r
+import info.bioinfweb.jphyloio.ReadWriteParameterMap;\r
+import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;\r
+import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;\r
+import info.bioinfweb.jphyloio.formats.JPhyloIOFormatIDs;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.TreeNode;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+\r
+import eu.etaxonomy.cdm.model.molecular.Sequence;\r
+import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
+import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
+import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;\r
+import eu.etaxonomy.taxeditor.molecular.io.CDMSequenceMatrixAdapter;\r
+\r
+\r
+\r
+/**\r
+ * Allows to exports a single read alignment to various alignment formats using\r
+ * <a href="http://bioinfweb.info/JPhyloIO/">JPhyloIO</a>.\r
+ *\r
+ * @author Ben Stöver\r
+ * @date 24.04.2016\r
+ */\r
+public class ExportSequenceToFileHandler extends AbstractHandler {\r
+    private static final JPhyloIOReaderWriterFactory factory = new JPhyloIOReaderWriterFactory();\r
+\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);\r
+        TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);\r
+        if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence) {\r
+            Sequence sequence = (Sequence)treeNodeOfSelection.getValue();\r
+\r
+            //TODO Collect the following information using a wizard.\r
+            File targetFile = new File("O:\\Projects\\Bereich BBI\\EDIT Campanula\\Testdaten\\NeXMLExport.xml");\r
+            String formatID = JPhyloIOFormatIDs.NEXML_FORMAT_ID;\r
+            ReadWriteParameterMap parameters = new ReadWriteParameterMap();\r
+            String consensusSequenceLabel = "Consensus sequence";\r
+\r
+            JPhyloIOEventWriter writer = factory.getWriter(formatID);\r
+\r
+            ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter();\r
+            document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, consensusSequenceLabel));\r
+\r
+            try {\r
+                writer.writeDocument(document, targetFile, parameters);\r
+            }\r
+            catch (IOException e) {\r
+                e.printStackTrace();\r
+                MessagingUtils.errorDialog("IO error", this,\r
+                        "An error occured when trying to export a consensus sequence alignment to the file \"" +\r
+                        targetFile.getAbsolutePath() + "\".", TaxeditorMolecularPlugin.PLUGIN_ID, e, false);  //TODO set pluginID\r
+                        //TODO Use multi language error message.\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+}\r
index f4c658084b6e9f38b80ac456b5a5565bfa3e4036..c4eb1c33c2f578d55eb063bee13e1080a465ce62 100644 (file)
@@ -27,7 +27,6 @@ import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
  * Displays an undistorted pherogram with {@link PherogramViewPart}.
  *
  * @author Ben Stöver
- *
  */
 public class ShowPherogramHandler extends AbstractHandler {
        public static void showPherogram(PherogramComponentModel model) throws PartInitException {
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/CDMSequenceMatrixAdapter.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/CDMSequenceMatrixAdapter.java
new file mode 100644 (file)
index 0000000..e3ab7f6
--- /dev/null
@@ -0,0 +1,160 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.molecular.io;\r
+\r
+\r
+import info.bioinfweb.commons.text.StringUtils;\r
+import info.bioinfweb.jphyloio.ReadWriteConstants;\r
+import info.bioinfweb.jphyloio.dataadapters.JPhyloIOEventReceiver;\r
+import info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter;\r
+import info.bioinfweb.jphyloio.dataadapters.implementations.NoSetsMatrixDataAdapter;\r
+import info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent;\r
+import info.bioinfweb.jphyloio.events.SequenceTokensEvent;\r
+import info.bioinfweb.jphyloio.events.type.EventContentType;\r
+\r
+import java.io.IOException;\r
+import java.util.Iterator;\r
+\r
+import eu.etaxonomy.cdm.model.molecular.Sequence;\r
+\r
+\r
+\r
+/**\r
+ * In implementation of {@link MatrixDataAdapter} that delegates to a {@link Sequence} object.\r
+ *\r
+ * @author Ben Stöver\r
+ * @date 29.04.2016\r
+ */\r
+public class CDMSequenceMatrixAdapter extends NoSetsMatrixDataAdapter implements ReadWriteConstants {\r
+    public static final String MATRIX_ID = DEFAULT_MATRIX_ID_PREFIX + "ContigAlignment";\r
+    public static final String SINGLE_READ_SEQUENCE_ID_PREFIX = DEFAULT_SEQUENCE_ID_PREFIX + "SingleRead";\r
+    public static final String CONSENSUS_SEQUENCE_ID= DEFAULT_SEQUENCE_ID_PREFIX + "Consensus";\r
+\r
+\r
+    private Sequence sequence;\r
+    private String consensusSequenceLabel;\r
+    //TODO Also allow specifying single read labels?\r
+\r
+\r
+    /**\r
+     * Creates a new instance of this class.\r
+     *\r
+     * @param sequence\r
+     * @param consensusSequenceLabel\r
+     */\r
+    public CDMSequenceMatrixAdapter(Sequence sequence, String consensusSequenceLabel) {\r
+        super();\r
+        this.sequence = sequence;\r
+        this.consensusSequenceLabel = consensusSequenceLabel;\r
+    }\r
+\r
+\r
+    /**\r
+     * @return the sequence\r
+     */\r
+    public Sequence getCDMSequence() {\r
+        return sequence;\r
+    }\r
+\r
+\r
+    private int extractSingleReadIndexFromID(String sequenceID) {\r
+        try {\r
+            return Integer.parseInt(sequenceID.substring(SINGLE_READ_SEQUENCE_ID_PREFIX.length()));\r
+        }\r
+        catch (NumberFormatException e) {\r
+            return -1;\r
+        }\r
+    }\r
+\r
+\r
+    @Override\r
+    public LinkedLabeledIDEvent getStartEvent() {\r
+        return new LinkedLabeledIDEvent(EventContentType.ALIGNMENT, MATRIX_ID, "Contig alignment", null);\r
+                //TODO Use label according to derivate and markers.\r
+    }\r
+\r
+\r
+    @Override\r
+    public boolean containsLongTokens() {\r
+        return false;\r
+    }\r
+\r
+\r
+    @Override\r
+    public long getColumnCount() {\r
+        return getCDMSequence().getSequenceString().length();  //TODO Consider that parts of single reads may lie outside of the current consensus sequence. Possibly return -1 in the future.\r
+    }\r
+\r
+\r
+    @Override\r
+    public long getSequenceCount() {\r
+        return /*sequence.getSingleReadAlignments().size() +*/ 1;\r
+    }\r
+\r
+\r
+    @Override\r
+    public Iterator<String> getSequenceIDIterator() {\r
+        return new SequenceIDIterator(getCDMSequence().getSingleReadAlignments().size());\r
+    }\r
+\r
+\r
+    @Override\r
+    public long getSequenceLength(String sequenceID) throws IllegalArgumentException {\r
+        int singleReadIndex = extractSingleReadIndexFromID(sequenceID);\r
+        if (singleReadIndex >= 0) {\r
+            //TODO Determine single read length. (Current problem: Reads are not ordered in the set of the Sequence object.)\r
+            return 0;\r
+        }\r
+        else if (CONSENSUS_SEQUENCE_ID.equals(sequenceID)) {\r
+            return getCDMSequence().getSequenceString().length();\r
+        }\r
+        else {\r
+            throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");\r
+        }\r
+    }\r
+\r
+\r
+    @Override\r
+    public LinkedLabeledIDEvent getSequenceStartEvent(String sequenceID) {\r
+        int singleReadIndex = extractSingleReadIndexFromID(sequenceID);\r
+        if (singleReadIndex >= 0) {\r
+            return new LinkedLabeledIDEvent(EventContentType.SEQUENCE, sequenceID, "singleRead" + singleReadIndex, null);\r
+                    //TODO Use name displayed in derivate hierarchy or specified name as label instead?\r
+        }\r
+        else if (CONSENSUS_SEQUENCE_ID.equals(sequenceID)) {\r
+            return new LinkedLabeledIDEvent(EventContentType.SEQUENCE, sequenceID, consensusSequenceLabel, null);\r
+        }\r
+        else {\r
+            throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");\r
+        }\r
+    }\r
+\r
+\r
+    @Override\r
+    public void writeSequencePartContentData(JPhyloIOEventReceiver receiver, String sequenceID, long startColumn,\r
+            long endColumn) throws IOException, IllegalArgumentException {\r
+\r
+        int singleReadIndex = extractSingleReadIndexFromID(sequenceID);\r
+        if (singleReadIndex >= 0) {\r
+            //TODO Implement single read output.\r
+        }\r
+        else if (CONSENSUS_SEQUENCE_ID.equals(sequenceID)) {\r
+            if (startColumn == 0) {\r
+                //TODO Add consensus sequence metadata.\r
+                //TODO Possibly export additional properties of sequence (e.g. isBarcode(), getDdbjId(), ...) as metadata.\r
+            }\r
+            receiver.add(new SequenceTokensEvent(StringUtils.charSequenceToStringList(\r
+                    getCDMSequence().getSequenceString().substring((int)startColumn, (int)endColumn))));\r
+        }\r
+        else {\r
+            throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");\r
+        }\r
+    }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/ExportSingleReadAlignmentWizardPage.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/ExportSingleReadAlignmentWizardPage.java
new file mode 100644 (file)
index 0000000..ddc149a
--- /dev/null
@@ -0,0 +1,91 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.molecular.io;\r
+\r
+\r
+import org.eclipse.jface.wizard.WizardPage;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.layout.FormAttachment;\r
+import org.eclipse.swt.layout.FormData;\r
+import org.eclipse.swt.layout.FormLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Text;\r
+\r
+\r
+\r
+/**\r
+ * Wizard page that allows to specify which parts of a single read alignment shall be exported to an alignment file.\r
+ *\r
+ * @author Ben St&ouml;ver\r
+ * @date 18.04.2016\r
+ */\r
+public class ExportSingleReadAlignmentWizardPage extends WizardPage {\r
+    private Text consensusSequenceNameTextField;\r
+    private Button exportConsensusSequenceCB;\r
+    private Button exportSingleReadsCB;\r
+\r
+\r
+    /**\r
+     * Create the wizard.\r
+     */\r
+    public ExportSingleReadAlignmentWizardPage() {\r
+        super("SingleReadSequencesExport");  //TODO Which pageName should be used here? Any conventions?\r
+        setTitle("Sequence export");\r
+        setDescription("Defines which sequences of the single read alignment shall be exported.");\r
+    }\r
+\r
+\r
+    /**\r
+     * Create contents of the wizard.\r
+     *\r
+     * @param parent the parent component\r
+     */\r
+    @Override\r
+    public void createControl(Composite parent) {\r
+        Composite container = new Composite(parent, SWT.NULL);\r
+\r
+        setControl(container);\r
+        container.setLayout(new FormLayout());\r
+\r
+        exportSingleReadsCB = new Button(container, SWT.CHECK);\r
+        exportSingleReadsCB.setSelection(true);\r
+        FormData fd_exportSingleReadsCB = new FormData();\r
+        fd_exportSingleReadsCB.top = new FormAttachment(0, 10);\r
+        fd_exportSingleReadsCB.left = new FormAttachment(0, 10);\r
+        exportSingleReadsCB.setLayoutData(fd_exportSingleReadsCB);\r
+        exportSingleReadsCB.setText("Export single reads");\r
+\r
+        exportConsensusSequenceCB = new Button(container, SWT.CHECK);\r
+        exportConsensusSequenceCB.setSelection(true);\r
+        exportConsensusSequenceCB.addSelectionListener(new SelectionAdapter() {\r
+            @Override\r
+            public void widgetSelected(SelectionEvent e) {\r
+                consensusSequenceNameTextField.setEnabled(exportConsensusSequenceCB.getSelection());\r
+            }\r
+        });\r
+        FormData fd_exportConsensusSequenceCB = new FormData();\r
+        fd_exportConsensusSequenceCB.top = new FormAttachment(exportSingleReadsCB, 6);\r
+        fd_exportConsensusSequenceCB.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);\r
+        exportConsensusSequenceCB.setLayoutData(fd_exportConsensusSequenceCB);\r
+        exportConsensusSequenceCB.setText("Export consensus sequence");\r
+\r
+        consensusSequenceNameTextField = new Text(container, SWT.BORDER);\r
+        consensusSequenceNameTextField.setText("ConsensusSequence");\r
+        FormData fd_consensusSequenceNameTextField = new FormData();\r
+        fd_consensusSequenceNameTextField.bottom = new FormAttachment(30);\r
+        fd_consensusSequenceNameTextField.right = new FormAttachment(28);\r
+        fd_consensusSequenceNameTextField.top = new FormAttachment(0, 62);\r
+        fd_consensusSequenceNameTextField.left = new FormAttachment(0, 32);\r
+        consensusSequenceNameTextField.setLayoutData(fd_consensusSequenceNameTextField);\r
+    }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIterator.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIterator.java
new file mode 100644 (file)
index 0000000..74f8ece
--- /dev/null
@@ -0,0 +1,65 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.molecular.io;\r
+\r
+import java.util.Iterator;\r
+import java.util.NoSuchElementException;\r
+\r
+\r
+\r
+/**\r
+ * Iterator implementation used internally be {@link CDMSequenceMatrixAdapter}.\r
+ *\r
+ * @author Ben Stöver\r
+ * @date 29.04.2016\r
+ */\r
+class SequenceIDIterator implements Iterator<String> {\r
+    private int singleReadPos;\r
+    private int singleReadCount;\r
+\r
+\r
+    /**\r
+     * Creates a new instance of this class.\r
+     *\r
+     * @param singleReadCount the number of single read IDs to be returned by this iterator before the consensus sequence\r
+     */\r
+    public SequenceIDIterator(int singleReadCount) {\r
+        super();\r
+        this.singleReadCount = singleReadCount;\r
+        this.singleReadPos = 0;\r
+    }\r
+\r
+\r
+    @Override\r
+    public boolean hasNext() {\r
+        return singleReadPos <= singleReadCount;\r
+    }\r
+\r
+\r
+    @Override\r
+    public String next() {\r
+        if (singleReadPos < singleReadCount) {\r
+            return CDMSequenceMatrixAdapter.SINGLE_READ_SEQUENCE_ID_PREFIX + (singleReadPos++);\r
+        }\r
+        else if (singleReadPos == singleReadCount) {\r
+            singleReadPos++;\r
+            return CDMSequenceMatrixAdapter.CONSENSUS_SEQUENCE_ID;\r
+        }\r
+        else {\r
+            throw new NoSuchElementException("There are no more sequence IDs availble from this iterator.");\r
+        }\r
+    }\r
+\r
+\r
+    @Override\r
+    public void remove() {\r
+        throw new UnsupportedOperationException("This iterator does not support removing elements.");\r
+    }\r
+}\r
diff --git a/eu.etaxonomy.taxeditor.molecular/src/test/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIteratorTest.java b/eu.etaxonomy.taxeditor.molecular/src/test/java/eu/etaxonomy/taxeditor/molecular/io/SequenceIDIteratorTest.java
new file mode 100644 (file)
index 0000000..23cf9f1
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.molecular.io;\r
+\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertTrue;\r
+\r
+import org.junit.Test;\r
+\r
+\r
+\r
+/**\r
+ * @author bstoe_01\r
+ * @date 29.04.2016\r
+ *\r
+ */\r
+public class SequenceIDIteratorTest {\r
+    //TODO Why can't this class access SequenceIDIterator from here? (Workaround: Copy to molecular projekt to run test.)\r
+\r
+    @Test\r
+    public void test_next() {\r
+        SequenceIDIterator iterator = new SequenceIDIterator(3);\r
+\r
+        for (int i = 0; i < 3; i++) {\r
+            assertTrue(iterator.hasNext());\r
+            assertEquals("seqSingleRead" + i, iterator.next());\r
+        }\r
+        assertTrue(iterator.hasNext());\r
+        assertEquals("seqConsensus", iterator.next());\r
+        assertFalse(iterator.hasNext());\r
+    }\r
+}\r