Project

General

Profile

Revision bcb823d5

IDbcb823d549bac3d3d764afbcfdaa38da5c7063ea
Parent 9a9359ce
Child 924ba372

Added by Ben Stöver about 4 years ago

Missing dependency Apache commons.lang added to molecular.lib.
Single read alignment export feature now makes use of wizard. (Selecting which sequences to export is not yet supported.)

View differences:

eu.etaxonomy.taxeditor.molecular.lib/.classpath
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	<classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.5.jar"/>
3 4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
4 5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 6
	<classpathentry exported="true" kind="lib" path="lib/owlapi-xmlutils-4.1.4.jar"/>
......
12 13
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.commons.swt/bin"/>
13 14
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.tic.core/bin"/>
14 15
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.tic.swt/bin"/>
15
	<classpathentry exported="true" kind="lib" path="lib/JPhyloIO/bin" sourcepath="lib/JPhyloIO/bin"/>
16
	<classpathentry exported="true" kind="lib" path="lib/JPhyloIO/bin" sourcepath="/JPhyloIO/src"/>
16 17
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.core/bin"/>
17 18
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.io/bin"/>
18 19
	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.swt/bin"/>
eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF
18 18
 lib/info.bioinfweb.libralign.core/bin/,
19 19
 lib/info.bioinfweb.libralign.io/bin/,
20 20
 lib/info.bioinfweb.libralign.swt/bin/,
21
 lib/info.bioinfweb.libralign.biojava1/bin/
21
 lib/info.bioinfweb.libralign.biojava1/bin/,
22
 lib/commons-lang3-3.5.jar
22 23
Export-Package: info.bioinfweb.commons,
23 24
 info.bioinfweb.commons.appversion,
24 25
 info.bioinfweb.commons.beans,
......
37 38
 info.bioinfweb.jphyloio,
38 39
 info.bioinfweb.jphyloio.dataadapters,
39 40
 info.bioinfweb.jphyloio.dataadapters.implementations,
40
 info.bioinfweb.jphyloio.dataadapters.implementations.store,
41 41
 info.bioinfweb.jphyloio.dataadapters.implementations.receivers,
42
 info.bioinfweb.jphyloio.dataadapters.implementations.store,
42 43
 info.bioinfweb.jphyloio.events,
43 44
 info.bioinfweb.jphyloio.events.meta,
44 45
 info.bioinfweb.jphyloio.events.type,
......
65 66
 info.bioinfweb.jphyloio.formats.text,
66 67
 info.bioinfweb.jphyloio.formats.xml,
67 68
 info.bioinfweb.jphyloio.formats.xtg,
68
 info.bioinfweb.jphyloio.utils,
69 69
 info.bioinfweb.jphyloio.objecttranslation,
70 70
 info.bioinfweb.jphyloio.objecttranslation.implementations,
71
 info.bioinfweb.jphyloio.utils,
71 72
 info.bioinfweb.libralign,
72 73
 info.bioinfweb.libralign.actions,
73 74
 info.bioinfweb.libralign.alignmentarea,
......
130 131
 org.apache.commons.collections4.splitmap,
131 132
 org.apache.commons.collections4.trie,
132 133
 org.apache.commons.collections4.trie.analyzer,
134
 org.apache.commons.lang3,
135
 org.apache.commons.lang3.builder,
136
 org.apache.commons.lang3.concurrent,
137
 org.apache.commons.lang3.event,
138
 org.apache.commons.lang3.exception,
139
 org.apache.commons.lang3.math,
140
 org.apache.commons.lang3.mutable,
141
 org.apache.commons.lang3.reflect,
142
 org.apache.commons.lang3.text,
143
 org.apache.commons.lang3.text.translate,
144
 org.apache.commons.lang3.time,
145
 org.apache.commons.lang3.tuple,
133 146
 org.biojava.bibliography,
134 147
 org.biojava.bio,
135 148
 org.biojava.bio.alignment,
eu.etaxonomy.taxeditor.molecular.lib/build.properties
13 13
               lib/info.bioinfweb.tic.core/bin/,\
14 14
               lib/info.bioinfweb.tic.swt/bin/,\
15 15
               lib/JPhyloIO/bin/,\
16
               lib/info.bioinfweb.libralign.biojava1/bin/
16
               lib/info.bioinfweb.libralign.biojava1/bin/,\
17
               lib/commons-lang3-3.5.jar
17 18
               lib/jphyloio-core-0-SNAPSHOT.jar,\
18 19
               lib/owlapi-xmlutils-4.1.4.jar
eu.etaxonomy.taxeditor.molecular.lib/pom.xml
28 28
                bioinfweb-commons-swt, bioinfweb-commons-core,
29 29
                bioinfweb-commons-bio, bioinfweb-commons-swing,
30 30
                tic-core, libralign-biojava1, core, sequencing, 
31
                tic-swt, jphyloio-core, owlapi-xmlutils, commons-collections4</includeArtifactIds>
31
                tic-swt, jphyloio-core, owlapi-xmlutils, 
32
                commons-lang3, commons-collections4</includeArtifactIds>
32 33
              <outputDirectory>lib</outputDirectory>
33 34
              <overWriteReleases>true</overWriteReleases>
34 35
              <overWriteSnapshots>true</overWriteSnapshots>
......
180 181
    </dependency>
181 182
    <!-- Apache commons -->
182 183
    <dependency>
184
        <groupId>org.apache.commons</groupId>
185
        <artifactId>commons-lang3</artifactId>
186
        <version>3.5</version>
187
    </dependency>
188
    <dependency>
183 189
      <groupId>org.apache.commons</groupId>
184 190
      <artifactId>commons-collections4</artifactId>
185 191
      <version>4.1</version>
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
15 15
import info.bioinfweb.jphyloio.ReadWriteParameterNames;
16 16
import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;
17 17
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
18
import info.bioinfweb.jphyloio.formats.JPhyloIOFormatIDs;
19 18
import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;
20 19

  
21
import java.io.File;
22 20
import java.io.IOException;
23 21

  
24 22
import org.eclipse.core.commands.AbstractHandler;
25 23
import org.eclipse.core.commands.ExecutionEvent;
26 24
import org.eclipse.core.commands.ExecutionException;
25
import org.eclipse.core.runtime.IStatus;
27 26
import org.eclipse.jface.viewers.ISelection;
28 27
import org.eclipse.jface.viewers.TreeNode;
28
import org.eclipse.jface.wizard.WizardDialog;
29 29
import org.eclipse.ui.handlers.HandlerUtil;
30 30

  
31 31
import eu.etaxonomy.cdm.model.molecular.Sequence;
......
35 35
import eu.etaxonomy.taxeditor.molecular.io.CDMPherogramAlignmentObjectTranslator;
36 36
import eu.etaxonomy.taxeditor.molecular.io.CDMSequenceMatrixAdapter;
37 37
import eu.etaxonomy.taxeditor.molecular.io.SingleReadAlignmentRDFXMLConstants;
38
import eu.etaxonomy.taxeditor.molecular.io.wizard.ExportSingleReadAlignmentWizard;
38 39

  
39 40

  
40 41

  
......
56 57
        if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence) {
57 58
            Sequence sequence = (Sequence)treeNodeOfSelection.getValue();
58 59

  
59
            //TODO Collect the following information using a wizard.
60
            File targetFile = new File("O:\\Projects\\Bereich BBI\\EDIT Campanula\\Testdaten\\NeXMLExport.xml");
61
            String formatID = JPhyloIOFormatIDs.NEXML_FORMAT_ID;
60
            final ExportSingleReadAlignmentWizard wizard = new ExportSingleReadAlignmentWizard();
61
            final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
62
            if (dialog.open() == IStatus.OK) {  //TODO Is the window disposed?
63
                // Prepare writer parameters:
64
                ReadWriteParameterMap parameters = new ReadWriteParameterMap();
65
                ObjectTranslatorFactory translatorFactory = new ObjectTranslatorFactory();
66
                translatorFactory.addXSDTranslators(true);
67
                translatorFactory.addTranslator(new CDMPherogramAlignmentObjectTranslator(), true, SingleReadAlignmentRDFXMLConstants.DATA_TYPE_PHERORAGM_ALIGNMENT);
68
                parameters.put(ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY, translatorFactory);
62 69

  
63
            ReadWriteParameterMap parameters = new ReadWriteParameterMap();
64
            ObjectTranslatorFactory translatorFactory = new ObjectTranslatorFactory();
65
            translatorFactory.addXSDTranslators(true);
66
            translatorFactory.addTranslator(new CDMPherogramAlignmentObjectTranslator(), true, SingleReadAlignmentRDFXMLConstants.DATA_TYPE_PHERORAGM_ALIGNMENT);
67
            parameters.put(ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY, translatorFactory);
70
                // Create writer and document adapters:
71
                JPhyloIOEventWriter writer = factory.getWriter(wizard.getSelectedFormat());
72
                ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter();
73
                document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, wizard.getConsensusSequenceLabel()));
68 74

  
69
            String consensusSequenceLabel = "Consensus sequence";
70
            JPhyloIOEventWriter writer = factory.getWriter(formatID);
71

  
72
            ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter();
73
            document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, consensusSequenceLabel));
74

  
75
            try {
76
                writer.writeDocument(document, targetFile, parameters);
77
            }
78
            catch (IOException e) {
79
                e.printStackTrace();
80
                MessagingUtils.errorDialog("IO error", this,
81
                        "An error occured when trying to export a consensus sequence alignment to the file \"" +
82
                        targetFile.getAbsolutePath() + "\".", TaxeditorMolecularPlugin.PLUGIN_ID, e, false);  //TODO set pluginID
83
                        //TODO Use multi language error message.
75
                // Write document:
76
                try {
77
                    writer.writeDocument(document, wizard.getSelectedFile(), parameters);
78
                }
79
                catch (IOException e) {
80
                    e.printStackTrace();
81
                    MessagingUtils.errorDialog("IO error", this,
82
                            "An error occured when trying to export a consensus sequence alignment to the file \"" +
83
                            wizard.getSelectedFile().getAbsolutePath() + "\".", TaxeditorMolecularPlugin.PLUGIN_ID, e, false);  //TODO set pluginID
84
                            //TODO Use multi language error message.
85
                }
84 86
            }
85 87
        }
86 88
        return null;
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java
10 10
package eu.etaxonomy.taxeditor.molecular.io.wizard;
11 11

  
12 12

  
13
import java.io.File;
14

  
13 15
import org.eclipse.jface.wizard.Wizard;
14 16

  
15 17

  
......
21 23
 * @date 23.06.2016
22 24
 */
23 25
public class ExportSingleReadAlignmentWizard extends Wizard {
26
    private ExportSingleReadAlignmentWizardPage page;
27

  
28
    private String selectedFormat = null;
29
    private File selectedFile = null;
30
    private String consensusSequenceLabel = null;
31

  
32

  
24 33
    public ExportSingleReadAlignmentWizard() {
25 34
        setWindowTitle("Export single read alignment");  //TODO Use multi languange message
26 35
    }
......
28 37

  
29 38
    @Override
30 39
    public void addPages() {
31
        addPage(new ExportSingleReadAlignmentWizardPage());
40
        page = new ExportSingleReadAlignmentWizardPage();
41
        addPage(page);
32 42
    }
33 43

  
34 44

  
35 45
    @Override
36 46
    public boolean performFinish() {
37
        return true;  //TODO Check inputs
47
        if (!page.getConsensusSequenceLabel().isEmpty()) {
48
            selectedFormat = page.getSelectedFormat();
49
            selectedFile = page.getSelectedFile();
50
            consensusSequenceLabel = page.getConsensusSequenceLabel();
51
            return true;
52
        }
53
        else {
54
            return false;  //TODO Display according error message in wizard heading, as long as valid inputs are not completed.
55
        }
56
    }
57

  
58

  
59
    public String getSelectedFormat() {
60
        return selectedFormat;
61
    }
62

  
63

  
64
    public File getSelectedFile() {
65
        return selectedFile;
66
    }
67

  
68

  
69
    public String getConsensusSequenceLabel() {
70
        return consensusSequenceLabel;
38 71
    }
39 72
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java
14 14
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
15 15
import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo;
16 16

  
17
import java.io.File;
17 18
import java.util.ArrayList;
18 19
import java.util.Collections;
19 20
import java.util.List;
......
158 159
        btnBrowse.setLayoutData(fd_btnBrowse);
159 160
        btnBrowse.setText("Browse...");
160 161

  
161
        formatComboBox = new Combo(container, SWT.NONE);
162
        formatComboBox = new Combo(container, SWT.READ_ONLY);
162 163
        for (JPhyloIOFormatInfo formatInfo : FORMATS) {
163 164
            formatComboBox.add(formatInfo.getFormatName());
164 165
        }
......
168 169
        fd_formatComboBox.top = new FormAttachment(lblFormat, 6);
169 170
        fd_formatComboBox.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
170 171
        formatComboBox.setLayoutData(fd_formatComboBox);
172
        formatComboBox.select(0);
171 173
    }
172 174

  
173 175

  
......
180 182
        if (formatComboBox != null) {
181 183
            int index = formatComboBox.getSelectionIndex();
182 184
            if (index > -1) {
183
                FORMATS.get(index).getFormatID();
185
                return FORMATS.get(index).getFormatID();
184 186
            }
185 187
        }
186 188
        return null;
187 189
    }
190

  
191

  
192
    public File getSelectedFile() {
193
        if (fileTextField !=  null) {
194
            return new File(fileTextField.getText());
195
        }
196
        else {
197
            return null;
198
        }
199
    }
200

  
201

  
202
    public String getConsensusSequenceLabel() {
203
        if (consensusSequenceNameTextField != null) {
204
            return consensusSequenceNameTextField.getText();
205
        }
206
        else {
207
            return null;
208
        }
209
    }
188 210
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)