1
|
/**
|
2
|
* Copyright (C) 2016 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.molecular.io.wizard;
|
10
|
|
11
|
|
12
|
import info.bioinfweb.jphyloio.events.type.EventContentType;
|
13
|
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
|
14
|
import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo;
|
15
|
|
16
|
import java.util.Collections;
|
17
|
import java.util.Map;
|
18
|
import java.util.TreeMap;
|
19
|
|
20
|
import org.eclipse.core.databinding.observable.value.IObservableValue;
|
21
|
import org.eclipse.core.databinding.observable.value.WritableValue;
|
22
|
|
23
|
|
24
|
|
25
|
/**
|
26
|
* The data model for a wizard to export single read alignments to different file formats using <i>JPhyloIO</i>.
|
27
|
*
|
28
|
* @author Ben Stöver
|
29
|
* @date 16.11.2016
|
30
|
*/
|
31
|
public class ExportSingleReadAlignmentWizardModel {
|
32
|
protected static final JPhyloIOReaderWriterFactory READER_WRITER_FACTORY = new JPhyloIOReaderWriterFactory();
|
33
|
protected static final Map<String, JPhyloIOFormatInfo> FORMAT_NAMES_TO_INFO_MAP = createFormatInfoList();
|
34
|
|
35
|
|
36
|
private IObservableValue exportSingleReads = new WritableValue(true, Boolean.class);
|
37
|
private IObservableValue exportConsensusSequence = new WritableValue(true, Boolean.class);
|
38
|
private IObservableValue consensusSequenceLabel = new WritableValue("ConsensusSequence", String.class);
|
39
|
private IObservableValue formatInfo = new WritableValue(null, String.class);
|
40
|
private IObservableValue fileName = new WritableValue(null, String.class);
|
41
|
|
42
|
|
43
|
private static Map<String, JPhyloIOFormatInfo> createFormatInfoList() {
|
44
|
Map<String, JPhyloIOFormatInfo> result = new TreeMap<String, JPhyloIOFormatInfo>();
|
45
|
for (String formatID : READER_WRITER_FACTORY.getFormatIDsSet()) {
|
46
|
JPhyloIOFormatInfo info = READER_WRITER_FACTORY.getFormatInfo(formatID);
|
47
|
if (info.isElementModeled(EventContentType.ALIGNMENT, false)) { // Check if the current format allows to write alignments.
|
48
|
result.put(info.getFormatName(), info);
|
49
|
}
|
50
|
}
|
51
|
return Collections.unmodifiableMap(result);
|
52
|
}
|
53
|
|
54
|
|
55
|
public boolean isExportSingleReads() {
|
56
|
return (Boolean)exportSingleReads.getValue();
|
57
|
}
|
58
|
|
59
|
|
60
|
protected IObservableValue getExportSingleReadsObservable() {
|
61
|
return exportSingleReads;
|
62
|
}
|
63
|
|
64
|
|
65
|
public boolean isExportConsensusSequence() {
|
66
|
return (Boolean)exportConsensusSequence.getValue();
|
67
|
}
|
68
|
|
69
|
|
70
|
protected IObservableValue getExportConsensusSequenceObservable() {
|
71
|
return exportConsensusSequence;
|
72
|
}
|
73
|
|
74
|
|
75
|
public String getConsensusSequenceLabel() {
|
76
|
return (String)consensusSequenceLabel.getValue();
|
77
|
}
|
78
|
|
79
|
|
80
|
protected IObservableValue getConsensusSequenceLabelObservable() {
|
81
|
return consensusSequenceLabel;
|
82
|
}
|
83
|
|
84
|
|
85
|
protected IObservableValue getFormatInfoObservable() {
|
86
|
return formatInfo;
|
87
|
}
|
88
|
|
89
|
|
90
|
/**
|
91
|
* Returns the <i>JPhyloIO</i> format info object to be used for exporting.
|
92
|
*
|
93
|
* @return the format info
|
94
|
*/
|
95
|
public JPhyloIOFormatInfo getFormatInfo() {
|
96
|
return FORMAT_NAMES_TO_INFO_MAP.get(formatInfo.getValue());
|
97
|
}
|
98
|
|
99
|
|
100
|
public String getFileName() {
|
101
|
return (String)fileName.getValue();
|
102
|
}
|
103
|
|
104
|
|
105
|
protected IObservableValue getFileNameObservable() {
|
106
|
return fileName;
|
107
|
}
|
108
|
}
|