Revision c4a7540a
Added by Patrick Plitzner about 7 years ago
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/CDMSequenceMatrixAdapter.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.molecular.io; |
11 | 11 |
|
12 | 12 |
|
13 |
import java.io.IOException; |
|
14 |
import java.net.URI; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.Collections; |
|
17 |
import java.util.Iterator; |
|
18 |
import java.util.List; |
|
19 |
|
|
20 |
import javax.xml.namespace.QName; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
|
23 |
import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment; |
|
24 |
import eu.etaxonomy.taxeditor.molecular.Messages; |
|
25 |
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor; |
|
13 | 26 |
import info.bioinfweb.commons.bio.CharacterStateSetType; |
14 | 27 |
import info.bioinfweb.commons.io.W3CXSConstants; |
15 | 28 |
import info.bioinfweb.commons.text.StringUtils; |
... | ... | |
27 | 40 |
import info.bioinfweb.jphyloio.events.type.EventContentType; |
28 | 41 |
import info.bioinfweb.jphyloio.utils.JPhyloIOWritingUtils; |
29 | 42 |
|
30 |
import java.io.IOException; |
|
31 |
import java.net.URI; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Collections; |
|
34 |
import java.util.Iterator; |
|
35 |
import java.util.List; |
|
36 |
|
|
37 |
import javax.xml.namespace.QName; |
|
38 |
|
|
39 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
|
40 |
import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment; |
|
41 |
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor; |
|
42 |
|
|
43 | 43 |
|
44 | 44 |
|
45 | 45 |
/** |
... | ... | |
52 | 52 |
* @date 29.04.2016 |
53 | 53 |
*/ |
54 | 54 |
public class CDMSequenceMatrixAdapter extends NoCharDefsNoSetsMatrixDataAdapter implements ReadWriteConstants, SingleReadAlignmentRDFXMLConstants { |
55 |
public static final String MATRIX_ID = DEFAULT_MATRIX_ID_PREFIX + "ContigAlignment"; |
|
56 |
public static final String SINGLE_READ_SEQUENCE_ID_PREFIX = DEFAULT_SEQUENCE_ID_PREFIX + "SingleRead"; |
|
57 |
public static final String CONSENSUS_SEQUENCE_ID= DEFAULT_SEQUENCE_ID_PREFIX + "Consensus"; |
|
55 |
|
|
56 |
private static final String NO_SEQUENCE_WITH_THE_ID_D_COULD_BE_FOUND = Messages.CDMSequenceMatrixAdapter_NO_SEQUENCE_FOUND; |
|
57 |
public static final String MATRIX_ID = DEFAULT_MATRIX_ID_PREFIX + "ContigAlignment"; //$NON-NLS-1$ |
|
58 |
public static final String SINGLE_READ_SEQUENCE_ID_PREFIX = DEFAULT_SEQUENCE_ID_PREFIX + "SingleRead"; //$NON-NLS-1$ |
|
59 |
public static final String CONSENSUS_SEQUENCE_ID= DEFAULT_SEQUENCE_ID_PREFIX + "Consensus"; //$NON-NLS-1$ |
|
58 | 60 |
|
59 | 61 |
|
60 | 62 |
private Sequence sequence; |
... | ... | |
79 | 81 |
public CDMSequenceMatrixAdapter(Sequence sequence, String consensusSequenceLabel, boolean exportConsensus, boolean exportSingleReads) { |
80 | 82 |
super(); |
81 | 83 |
if (!exportConsensus && !exportSingleReads) { |
82 |
throw new IllegalArgumentException("Either exportConsensus or exportSingleReads must be true. " |
|
83 |
+ "Otherwise no sequences would be contained in this matrix."); |
|
84 |
throw new IllegalArgumentException(Messages.CDMSequenceMatrixAdapter_EITHER_MUST_BE_TRUE); |
|
84 | 85 |
} |
85 | 86 |
else { |
86 | 87 |
this.sequence = sequence; |
... | ... | |
131 | 132 |
|
132 | 133 |
@Override |
133 | 134 |
public LinkedLabeledIDEvent getStartEvent(ReadWriteParameterMap parameters) { |
134 |
return new LinkedLabeledIDEvent(EventContentType.ALIGNMENT, MATRIX_ID, "Contig alignment", null); |
|
135 |
return new LinkedLabeledIDEvent(EventContentType.ALIGNMENT, MATRIX_ID, "Contig alignment", null); //$NON-NLS-1$
|
|
135 | 136 |
//TODO Use label according to derivate and markers. |
136 | 137 |
} |
137 | 138 |
|
... | ... | |
180 | 181 |
return getCDMSequence().getSequenceString().length(); |
181 | 182 |
} |
182 | 183 |
else { |
183 |
throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");
|
|
184 |
throw new IllegalArgumentException(String.format(NO_SEQUENCE_WITH_THE_ID_D_COULD_BE_FOUND, sequenceID));
|
|
184 | 185 |
} |
185 | 186 |
} |
186 | 187 |
|
... | ... | |
189 | 190 |
public LinkedLabeledIDEvent getSequenceStartEvent(ReadWriteParameterMap parameters, String sequenceID) { |
190 | 191 |
int singleReadIndex = extractSingleReadIndexFromID(sequenceID); |
191 | 192 |
if (singleReadIndex >= 0) { |
192 |
return new LinkedLabeledIDEvent(EventContentType.SEQUENCE, sequenceID, "Single read " + singleReadIndex, null); |
|
193 |
return new LinkedLabeledIDEvent(EventContentType.SEQUENCE, sequenceID, "Single read " + singleReadIndex, null); //$NON-NLS-1$
|
|
193 | 194 |
//TODO Use name displayed in derivate hierarchy or specified name as label instead? |
194 | 195 |
} |
195 | 196 |
else if (exportConsensus && CONSENSUS_SEQUENCE_ID.equals(sequenceID)) { |
196 | 197 |
return new LinkedLabeledIDEvent(EventContentType.SEQUENCE, sequenceID, consensusSequenceLabel, null); |
197 | 198 |
} |
198 | 199 |
else { |
199 |
throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");
|
|
200 |
throw new IllegalArgumentException(String.format(NO_SEQUENCE_WITH_THE_ID_D_COULD_BE_FOUND, sequenceID));
|
|
200 | 201 |
} |
201 | 202 |
} |
202 | 203 |
|
... | ... | |
210 | 211 |
|
211 | 212 |
|
212 | 213 |
private String createMetadataID(String sequenceID, QName predicate) { |
213 |
return sequenceID + "META" + predicate.getLocalPart(); |
|
214 |
return sequenceID + "META" + predicate.getLocalPart(); //$NON-NLS-1$
|
|
214 | 215 |
} |
215 | 216 |
|
216 | 217 |
|
... | ... | |
256 | 257 |
writeStringPart(receiver, getCDMSequence().getSequenceString(), startColumn, endColumn); |
257 | 258 |
} |
258 | 259 |
else { |
259 |
throw new IllegalArgumentException("No sequence with the ID \"" + sequenceID + "\" could be found.");
|
|
260 |
throw new IllegalArgumentException(String.format(NO_SEQUENCE_WITH_THE_ID_D_COULD_BE_FOUND, sequenceID));
|
|
260 | 261 |
} |
261 | 262 |
} |
262 | 263 |
|
Also available in: Unified diff
ref #4611 i18n for molecular plugin