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
**/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
<classpathentry exported="true" kind="lib" path="lib/sequencing-1.9.2-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/tic-core-2-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/tic-swt-2-SNAPSHOT.jar"/>
+ <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>
lib/libralign-swt-0-SNAPSHOT.jar,
lib/sequencing-1.9.2-SNAPSHOT.jar,
lib/tic-core-2-SNAPSHOT.jar,
- lib/tic-swt-2-SNAPSHOT.jar
+ lib/tic-swt-2-SNAPSHOT.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,
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,
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
lib/libralign-swt-0-SNAPSHOT.jar,\
lib/sequencing-1.9.2-SNAPSHOT.jar,\
lib/tic-core-2-SNAPSHOT.jar,\
- lib/tic-swt-2-SNAPSHOT.jar
+ lib/tic-swt-2-SNAPSHOT.jar,\
+ lib/jphyloio-core-0-SNAPSHOT.jar,\
+ lib/owlapi-xmlutils-4.1.4.jar
<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-SNAPSHOT</version>
</dependency>
- <!-- commons -->
+ <!-- bioinfweb.commons -->
<dependency>
<groupId>info.bioinfweb.commons.java</groupId>
<artifactId>bioinfweb-commons-swt</artifactId>
<artifactId>bioinfweb-commons-swing</artifactId>
<version>2-SNAPSHOT</version>
</dependency>
- <!-- tic -->
+ <!-- TIC -->
<dependency>
<groupId>info.bioinfweb.tic</groupId>
<artifactId>tic-core</artifactId>
<artifactId>tic-swt</artifactId>
<version>2-SNAPSHOT</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>
<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>
/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
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
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
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
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
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
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"
--- /dev/null
+// $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
* Displays an undistorted pherogram with {@link PherogramViewPart}.
*
* @author Ben Stöver
- *
*/
public class ShowPherogramHandler extends AbstractHandler {
public static void showPherogram(PherogramComponentModel model) throws PartInitException {
--- /dev/null
+// $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
--- /dev/null
+// $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ö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
--- /dev/null
+// $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
--- /dev/null
+// $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