2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.molecular
.io
.wizard
;
12 import info
.bioinfweb
.commons
.bio
.SequenceUtils
;
13 import info
.bioinfweb
.jphyloio
.events
.type
.EventContentType
;
14 import info
.bioinfweb
.jphyloio
.factory
.JPhyloIOReaderWriterFactory
;
15 import info
.bioinfweb
.jphyloio
.formatinfo
.JPhyloIOFormatInfo
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Collections
;
19 import java
.util
.List
;
21 import org
.eclipse
.core
.databinding
.observable
.value
.IObservableValue
;
22 import org
.eclipse
.core
.databinding
.observable
.value
.WritableValue
;
27 * The data model for a wizard to export single read alignments to different file formats using <i>JPhyloIO</i>.
32 public class ExportSingleReadAlignmentWizardModel
{
33 protected static final JPhyloIOReaderWriterFactory READER_WRITER_FACTORY
= new JPhyloIOReaderWriterFactory();
34 protected static final List
<JPhyloIOFormatInfo
> FORMATS
= createFormatInfoList();
37 private IObservableValue formatInfo
= new WritableValue(0, Integer
.class);
38 private IObservableValue fileName
= new WritableValue(null, String
.class);
39 private IObservableValue exportSingleReads
= new WritableValue(true, Boolean
.class);
40 private IObservableValue exportConsensusSequence
= new WritableValue(true, Boolean
.class);
41 private IObservableValue consensusSequenceLabel
= new WritableValue("Consensus", String
.class);
42 private IObservableValue elongateSequences
= new WritableValue(false, Boolean
.class);
43 private IObservableValue useGapToken
= new WritableValue(true, Boolean
.class);
46 private static List
<JPhyloIOFormatInfo
> createFormatInfoList() {
47 List
<JPhyloIOFormatInfo
> result
= new ArrayList
<JPhyloIOFormatInfo
>();
48 for (String formatID
: READER_WRITER_FACTORY
.getFormatIDsSet()) {
49 JPhyloIOFormatInfo info
= READER_WRITER_FACTORY
.getFormatInfo(formatID
);
50 if (info
.isElementModeled(EventContentType
.ALIGNMENT
, false)) { // Check if the current format allows to write alignments.
54 return Collections
.unmodifiableList(result
);
58 protected IObservableValue
getFormatInfoObservable() {
64 * Returns the <i>JPhyloIO</i> format info object to be used for exporting.
66 * @return the format info
68 public JPhyloIOFormatInfo
getFormatInfo() {
69 return FORMATS
.get((Integer
)formatInfo
.getValue());
73 public String
getFileName() {
74 return (String
)fileName
.getValue();
78 protected IObservableValue
getFileNameObservable() {
83 public boolean isExportSingleReads() {
84 return (Boolean
)exportSingleReads
.getValue();
88 protected IObservableValue
getExportSingleReadsObservable() {
89 return exportSingleReads
;
93 public boolean isExportConsensusSequence() {
94 return (Boolean
)exportConsensusSequence
.getValue();
98 protected IObservableValue
getExportConsensusSequenceObservable() {
99 return exportConsensusSequence
;
103 public String
getConsensusSequenceLabel() {
104 return (String
)consensusSequenceLabel
.getValue();
108 protected IObservableValue
getConsensusSequenceLabelObservable() {
109 return consensusSequenceLabel
;
113 public String
getElongationToken() {
114 if ((Boolean
)elongateSequences
.getValue()) {
115 if ((Boolean
)useGapToken
.getValue()) {
116 return Character
.toString(SequenceUtils
.GAP_CHAR
);
119 return Character
.toString(SequenceUtils
.MISSING_DATA_CHAR
);
128 protected IObservableValue
getElongateSequencesObservable() {
129 return elongateSequences
;
133 protected IObservableValue
getUseGapTokenObservable() {