9add0c797bb4dc7595ca7f0b239eb534ca52a1e1
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / molecular / AlignmentEditor.java
1 // $Id$
2 /**
3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.editor.molecular;
11
12
13 import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
14 import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
15 import info.bioinfweb.libralign.dataarea.implementations.ConsensusSequenceArea;
16 import info.bioinfweb.libralign.dataarea.implementations.SequenceIndexArea;
17 import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramAlignmentModel;
18 import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
19 import info.bioinfweb.libralign.dataarea.implementations.pherogram.ShiftChange;
20 import info.bioinfweb.libralign.editsettings.EditSettingsChangeEvent;
21 import info.bioinfweb.libralign.editsettings.EditSettingsListener;
22 import info.bioinfweb.libralign.multiplealignments.AlignmentAreaList;
23 import info.bioinfweb.libralign.multiplealignments.MultipleAlignmentsContainer;
24 import info.bioinfweb.libralign.pherogram.provider.BioJavaPherogramProvider;
25 import info.bioinfweb.libralign.pherogram.provider.PherogramProvider;
26 import info.bioinfweb.libralign.pherogram.provider.ReverseComplementPherogramProvider;
27 import info.bioinfweb.libralign.sequenceprovider.SequenceDataChangeListener;
28 import info.bioinfweb.libralign.sequenceprovider.SequenceDataProvider;
29 import info.bioinfweb.libralign.sequenceprovider.SequenceUtils;
30 import info.bioinfweb.libralign.sequenceprovider.adapters.StringAdapter;
31 import info.bioinfweb.libralign.sequenceprovider.events.SequenceChangeEvent;
32 import info.bioinfweb.libralign.sequenceprovider.events.SequenceRenamedEvent;
33 import info.bioinfweb.libralign.sequenceprovider.events.TokenChangeEvent;
34 import info.bioinfweb.libralign.sequenceprovider.implementations.PackedSequenceDataProvider;
35 import info.bioinfweb.libralign.sequenceprovider.tokenset.BioJavaTokenSet;
36 import info.bioinfweb.libralign.sequenceprovider.tokenset.TokenSet;
37
38 import java.io.File;
39 import java.io.IOException;
40 import java.io.InputStream;
41 import java.net.URI;
42 import java.util.ArrayList;
43 import java.util.Collection;
44 import java.util.Collections;
45 import java.util.Iterator;
46 import java.util.Map;
47 import java.util.TreeMap;
48
49 import org.biojava.bio.chromatogram.ChromatogramFactory;
50 import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;
51 import org.biojava3.core.sequence.compound.DNACompoundSet;
52 import org.biojava3.core.sequence.compound.NucleotideCompound;
53 import org.eclipse.core.runtime.IProgressMonitor;
54 import org.eclipse.swt.SWT;
55 import org.eclipse.swt.widgets.Composite;
56 import org.eclipse.ui.IActionBars;
57 import org.eclipse.ui.IEditorInput;
58 import org.eclipse.ui.IEditorPart;
59 import org.eclipse.ui.IEditorSite;
60 import org.eclipse.ui.PartInitException;
61 import org.eclipse.ui.PlatformUI;
62 import org.eclipse.ui.commands.ICommandService;
63 import org.eclipse.ui.part.EditorPart;
64
65 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
66 import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
67 import eu.etaxonomy.cdm.model.media.MediaUtils;
68 import eu.etaxonomy.cdm.model.molecular.Sequence;
69 import eu.etaxonomy.cdm.model.molecular.SequenceString;
70 import eu.etaxonomy.cdm.model.molecular.SingleRead;
71 import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment;
72 import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleInsertOverwriteHandler;
73 import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleLeftRightInsertionHandler;
74 import eu.etaxonomy.taxeditor.store.CdmStore;
75
76
77
78 /**
79 * Editor component to edit a contig alignment used to combine different overlapping pherograms from Sanger sequencing to
80 * a consensus sequence.
81 * <p>
82 * The contained GUI components used to edit the alignment come from <a href="http://bioinfweb.info/LibrAlign/">LibrAlign</a>.
83 *
84 * @author Ben Stöver
85 * @author pplitzner
86 * @date 04.08.2014
87 */
88 public class AlignmentEditor extends EditorPart {
89 public static final String ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor";
90
91 public static final int READS_AREA_INDEX = 1;
92 public static final int CONSENSUS_AREA_INDEX = READS_AREA_INDEX + 1;
93 public static final int PHEROGRAM_AREA_INDEX = 0;
94 public static final String DEFAULT_READ_NAME_PREFIX = "Read ";
95 public static final String CONSENSUS_NAME = "Consensus";
96
97
98 private final ConversationHolder conversationHolder;
99
100 private final SequenceDataChangeListener DIRTY_LISTENER = new SequenceDataChangeListener() {
101 @Override
102 public <T> void afterTokenChange(TokenChangeEvent<T> e) {
103 setDirty();
104 }
105
106 @Override
107 public <T> void afterSequenceRenamed(SequenceRenamedEvent<T> e) {
108 setDirty();
109 }
110
111 @Override
112 public <T> void afterSequenceChange(SequenceChangeEvent<T> e) {
113 setDirty();
114 }
115
116 @Override
117 public <T, U> void afterProviderChanged(SequenceDataProvider<T> oldProvider,
118 SequenceDataProvider<U> newProvider) { // Not expected.
119
120 setDirty();
121 }
122 };
123
124 private MultipleAlignmentsContainer alignmentsContainer = null;
125 private final Map<Integer, SingleReadAlignment> cdmMap = new TreeMap<Integer, SingleReadAlignment>(); //TODO Move this to ContigSequenceDataProvider
126 private boolean dirty = false;
127
128
129 public AlignmentEditor() {
130 conversationHolder = null; //CdmStore.createConversation();
131 }
132
133
134 private void refreshToolbarElement(String id) {
135 ICommandService commandService =
136 (ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
137 if (commandService != null) {
138 commandService.refreshElements(id, Collections.EMPTY_MAP);
139 }
140 }
141
142
143 private void registerEditSettingListener(MultipleAlignmentsContainer container) {
144 container.getEditSettings().addListener(new EditSettingsListener() {
145 @Override
146 public void workingModeChanged(EditSettingsChangeEvent e) {} // Currently nothing to do
147
148 @Override
149 public void insertLeftInDataAreaChanged(EditSettingsChangeEvent e) {
150 updateStatusBar();
151 refreshToolbarElement(ToggleLeftRightInsertionHandler.COMMAND_ID);
152 }
153
154 @Override
155 public void insertChanged(EditSettingsChangeEvent e) {
156 updateStatusBar();
157 refreshToolbarElement(ToggleInsertOverwriteHandler.COMMAND_ID);
158 }
159 });
160 }
161
162
163 private AlignmentArea createIndexArea(MultipleAlignmentsContainer container) {
164 AlignmentArea result = new AlignmentArea(container);
165 result.setAllowVerticalScrolling(false);
166 result.getDataAreas().getTopAreas().add(new SequenceIndexArea(result.getContentArea()));
167 return result;
168 }
169
170
171 private AlignmentArea createEditableAlignmentArea(MultipleAlignmentsContainer container, boolean allowVerticalScrolling) {
172 AlignmentArea result = new AlignmentArea(container);
173 result.setAllowVerticalScrolling(allowVerticalScrolling);
174
175 TokenSet<NucleotideCompound> tokenSet = new BioJavaTokenSet<NucleotideCompound>(new DNACompoundSet(), true);
176 SequenceDataProvider<NucleotideCompound> provider = new PackedSequenceDataProvider<NucleotideCompound>(tokenSet);
177 result.setSequenceProvider(provider, false);
178 provider.getChangeListeners().add(DIRTY_LISTENER);
179
180 return result;
181 }
182
183
184 private AlignmentArea createConsensusHintArea(MultipleAlignmentsContainer container,
185 SequenceDataProvider<?> sequenceProvider) {
186
187 AlignmentArea result = new AlignmentArea(container);
188 result.setAllowVerticalScrolling(false);
189 result.getDataAreas().getBottomAreas().add(
190 new ConsensusSequenceArea(result.getContentArea(), sequenceProvider));
191 return result;
192 }
193
194
195 private MultipleAlignmentsContainer getAlignmentsContainer() {
196 if (alignmentsContainer == null) {
197 alignmentsContainer = new MultipleAlignmentsContainer();
198
199 AlignmentAreaList list = alignmentsContainer.getAlignmentAreas();
200 list.add(createIndexArea(alignmentsContainer));
201 AlignmentArea readsArea = createEditableAlignmentArea(alignmentsContainer, true);
202 list.add(readsArea); // Make sure READS_AREA_INDEX is correct.
203 list.add(createEditableAlignmentArea(alignmentsContainer, false)); // Make sure COMSENSUS_AREA_INDEX is correct.
204 list.add(createConsensusHintArea(alignmentsContainer,
205 readsArea.getSequenceProvider()));
206
207 registerEditSettingListener(alignmentsContainer);
208 }
209 return alignmentsContainer;
210 }
211
212
213 private AlignmentArea getReadsArea() {
214 return getAlignmentsContainer().getAlignmentAreas().get(READS_AREA_INDEX);
215 }
216
217
218 private AlignmentArea getConsensusArea() {
219 return getAlignmentsContainer().getAlignmentAreas().get(CONSENSUS_AREA_INDEX);
220 }
221
222
223 private PherogramArea getPherogramArea(int sequenceID) {
224 return (PherogramArea)getReadsArea().getDataAreas().getSequenceAreas(sequenceID).get(PHEROGRAM_AREA_INDEX);
225 }
226
227
228 private void createTestContents() {
229 // Just for testing:
230 try {
231 addRead(new File("D:/Users/BenStoever/Documents/Studium/Projekte/Promotion/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR430_JR-P01.ab1").toURI(), false);
232 addRead(new File("D:/Users/BenStoever/Documents/Studium/Projekte/Promotion/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1").toURI(), false);
233
234 // Add test consensus sequence:
235 SequenceDataProvider consensusProvider = getConsensusArea().getSequenceProvider();
236 int id = consensusProvider.addSequence(CONSENSUS_NAME);
237 Collection<Object> tokens = new ArrayList<Object>(); // First save tokens in a collection to avoid GUI updated for each token.
238 tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('A'));
239 tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('C'));
240 tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('G'));
241 tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('T'));
242 consensusProvider.insertTokensAt(id, 0, tokens);
243 }
244 catch (Exception e) {
245 throw new RuntimeException(e);
246 }
247 }
248
249
250 private void readCDMData(Sequence sequenceNode) {
251 //TODO If called from somewhere else than createPartControl() the editorInput needs to be checked and previous contents need to be cleared (or updated).
252
253 // Add reads:
254 for (SingleReadAlignment singleReadAlignment : sequenceNode.getSingleReadAlignments()) {
255 try {
256 SingleRead pherogramInfo = singleReadAlignment.getSingleRead();
257 int id = addRead(pherogramInfo.getPrimer().getLabel(), //TODO Should the sequence name contain other/additional/alternative data? Can the same string as in the derivative tree be used here?
258 MediaUtils.getFirstMediaRepresentationPart(pherogramInfo.getPherogram()).getUri(),
259 singleReadAlignment.isReverseComplement(),
260 singleReadAlignment.getEditedSequence(),
261 singleReadAlignment.getShifts());
262 cdmMap.put(id, singleReadAlignment);
263 }
264 catch (IOException e) {
265 e.printStackTrace(); //TODO Output to user (Possibly collect for all pherograms and display in the end.)
266 }
267 catch (UnsupportedChromatogramFormatException e) {
268 e.printStackTrace(); //TODO Output to user (Possibly collect for all pherograms and display in the end.)
269 }
270 }
271
272 // Set consensus sequence:
273 SequenceDataProvider consensusProvider = getConsensusArea().getSequenceProvider();
274 int id = consensusProvider.addSequence(CONSENSUS_NAME);
275 consensusProvider.insertTokensAt(id, 0, SequenceUtils.stringToTokenList(
276 sequenceNode.getConsensusSequence().getString(), consensusProvider.getTokenSet()));
277 //TODO Can the consensus sequence also be null? / Should it be created here, if nothing is in the DB?
278 }
279
280
281 /* (non-Javadoc)
282 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
283 */
284 @Override
285 public void createPartControl(Composite parent) {
286 getAlignmentsContainer().createSWTWidget(parent, SWT.NONE);
287 updateStatusBar();
288
289 if (getEditorInput() instanceof AlignmentEditorInput) {
290 if (((AlignmentEditorInput)getEditorInput()).getSequenceNode() != null) {
291 Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
292 //re-load into the current session if it is already persisted in the DB
293 if(sequenceNode!=null && sequenceNode.getId()!=0){
294 sequenceNode = CdmStore.getService(ISequenceService.class).load(sequenceNode.getUuid());
295 }
296 readCDMData(sequenceNode);
297 }
298 else {
299 createTestContents(); // This case will removed after the test phase and an exception should probably be thrown.
300 }
301 }
302 else {
303 throw new IllegalArgumentException("The editor input must have the type " +
304 AlignmentEditorInput.class.getCanonicalName()); //TODO What should be done here?
305 }
306 }
307
308
309 private void updateStatusBar() {
310 IActionBars bars = getEditorSite().getActionBars();
311 bars.getStatusLineManager().setMessage("Edit mode: " +
312 (getReadsArea().getEditSettings().isInsert() ? "Insert" : "Overwrite") + " " +
313 "Insertion in pherogram: " +
314 (getReadsArea().getEditSettings().isInsertLeftInDataArea() ? "Left" : "Right"));
315 }
316
317
318 private SingleReadAlignment.Shift[] convertToCDMShifts(PherogramAlignmentModel alignmentModel) {
319 SingleReadAlignment.Shift[] result = new SingleReadAlignment.Shift[alignmentModel.getShiftChangeCount()];
320 Iterator<ShiftChange> iterator = alignmentModel.shiftChangeIterator();
321 int pos = 0;
322 while (iterator.hasNext()) {
323 ShiftChange shiftChange = iterator.next();
324 result[pos] = new SingleReadAlignment.Shift(shiftChange.getBaseCallIndex(), shiftChange.getShiftChange());
325 }
326 return result;
327 }
328
329
330 /* (non-Javadoc)
331 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
332 */
333 @Override
334 public void doSave(IProgressMonitor monitor) {
335 if (getEditorInput() instanceof AlignmentEditorInput) {
336 String taskName = "Saving alignment";
337 monitor.beginTask(taskName, 3);
338
339 Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
340 StringAdapter stringProvider = new StringAdapter(getConsensusArea().getSequenceProvider(), false); // Throws an exception if a token has more than one character.
341
342 // Write consensus sequence:
343 SequenceString consensusSequenceObj = sequenceNode.getConsensusSequence();
344 String newConsensusSequence = stringProvider.getSequence(
345 getConsensusArea().getSequenceProvider().sequenceIDByName(CONSENSUS_NAME));
346 if (consensusSequenceObj == null) {
347 sequenceNode.setConsensusSequence(SequenceString.NewInstance(newConsensusSequence));
348 }
349 else {
350 consensusSequenceObj.setString(newConsensusSequence);
351 }
352
353 // Write single reads:
354 stringProvider.setUnderlyingProvider(getReadsArea().getSequenceProvider());
355 sequenceNode.getSingleReadAlignments().retainAll(cdmMap.values()); // Remove all reads that are not in the alignment anymore.
356 Iterator<Integer> iterator = getReadsArea().getSequenceProvider().sequenceIDIterator();
357 while (iterator.hasNext()) {
358 int id = iterator.next();
359 SingleReadAlignment singleRead = cdmMap.get(id);
360 if (singleRead == null) {
361 //TODO Create new read object. => Shall it be allowed to add reads in the alignment editor which are not represented in the CDM tree before the alignment editor is saved?
362 //singleRead = SingleReadAlignment.NewInstance(consensusSequence, singleRead, shifts, editedSequence);
363 }
364
365 singleRead.setEditedSequence(stringProvider.getSequence(id));
366 singleRead.setReverseComplement(getPherogramArea(id).getProvider() instanceof ReverseComplementPherogramProvider); // Works only if ReverseComplementPherogramProvider instances are not nested.
367 singleRead.setShifts(convertToCDMShifts(getPherogramArea(id).getAlignmentModel()));
368 }
369
370 if (!conversationHolder.isBound()) {
371 conversationHolder.bind();
372 }
373 monitor.worked(1);
374
375 // Commit the conversation and start a new transaction immediately:
376 conversationHolder.commit(true);
377 monitor.worked(1);
378
379 dirty = false;
380 monitor.worked(1);
381 monitor.done();
382 firePropertyChange(PROP_DIRTY);
383 }
384 else {
385 //TODO Throw exception as soon as testing period which allows unlinked AlignmentEditor is over.
386 }
387 }
388
389
390 /* (non-Javadoc)
391 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
392 */
393 @Override
394 public void doSaveAs() {}
395
396
397 /* (non-Javadoc)
398 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
399 */
400 @Override
401 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
402 setSite(site);
403 setInput(input);
404 }
405
406
407 /* (non-Javadoc)
408 * @see org.eclipse.ui.part.EditorPart#isDirty()
409 */
410 @Override
411 public boolean isDirty() {
412 return dirty;
413 }
414
415
416 private void setDirty() {
417 dirty = true;
418 firePropertyChange(IEditorPart.PROP_DIRTY);
419 }
420
421
422 /* (non-Javadoc)
423 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
424 */
425 @Override
426 public boolean isSaveAsAllowed() {
427 return false; // "Save as" not allowed.
428 }
429
430
431 @Override
432 public void setFocus() {
433 if(conversationHolder!=null){
434 conversationHolder.bind();
435 }
436 }
437
438
439 public boolean isInsertMode() {
440 return getAlignmentsContainer().getEditSettings().isInsert();
441 }
442
443
444 public boolean isInsertLeftInPherogram() {
445 return getAlignmentsContainer().getEditSettings().isInsertLeftInDataArea();
446 }
447
448
449 public void toggleLeftRightInsertionInPherogram() {
450 getAlignmentsContainer().getEditSettings().toggleInsertLeftInDataArea();
451 }
452
453
454 public void toggleInsertOverwrite() {
455 getAlignmentsContainer().getEditSettings().toggleInsert();
456 }
457
458
459 public void reverseComplementSelection() {
460 SelectionModel selection = getReadsArea().getSelection();
461 SequenceDataProvider<?> provider = getReadsArea().getSequenceProvider();
462 for (int row = selection.getStartRow(); row < selection.getStartRow() + selection.getCursorHeight(); row++) {
463 int sequenceID = getReadsArea().getSequenceOrder().idByIndex(row);
464 //TODO rc edited sequence
465
466 if (getPherogramArea(sequenceID).getProvider() instanceof ReverseComplementPherogramProvider) {
467 //getPherogramArea(sequenceID).
468 //TODO Allow to set new provider in PherogramArea or create new PherogramArea
469 //TODO Reposition pherogram according to previous position in edited sequence and length
470 }
471 }
472 }
473
474
475 public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException {
476 PherogramProvider result;
477 InputStream stream = uri.toURL().openStream();
478 try {
479 result = new BioJavaPherogramProvider(ChromatogramFactory.create(stream));
480 }
481 finally {
482 stream.close();
483 }
484 return result;
485 }
486
487
488 private String newReadName() {
489 int index = 1;
490 while (getReadsArea().getSequenceProvider().sequenceIDByName(DEFAULT_READ_NAME_PREFIX + index)
491 != SequenceDataProvider.NO_SEQUENCE_FOUND) {
492
493 index++;
494 }
495 return DEFAULT_READ_NAME_PREFIX + index;
496 }
497
498
499 public void addRead(URI pherogramURI, boolean reverseComplemented) throws IOException, UnsupportedChromatogramFormatException {
500 addRead(newReadName(), pherogramURI, reverseComplemented, null, null);
501 }
502
503
504 /**
505 * Adds a new sequence with attached phergram data area to the reads alignment.
506 * <p>
507 * If {@code null} is specified as {@code editedSequence} the base call sequence from the pherogram will
508 * be set as the edited sequence. If {@code null} is specified as {@code shifts} no shifts between the edited
509 * and the base calls sequence are assumed.
510 *
511 * @param name the name of the new sequence
512 * @param pherogramURI the URI where the associated pherogram file is located
513 * @param reverseComplemented Specify {@code true} here, if the reverse complement of the pherogram data should
514 * be added, {@code false} otherwise.
515 * @param editedSequence the edited version of the base call sequence (May be {@code null}.)
516 * @param shifts the alignment information that links the edited and the base call sequence (May be {@code null}.)
517 * @return the sequence ID of the added read
518 * @throws IOException if an error occurred when trying to read the pherogram file
519 * @throws UnsupportedChromatogramFormatException if the format of the pherogram file is not supported
520 */
521 public int addRead(String name, URI pherogramURI, boolean reverseComplemented, String editedSequence,
522 SingleReadAlignment.Shift[] shifts) throws IOException, UnsupportedChromatogramFormatException {
523
524 SequenceDataProvider provider = getReadsArea().getSequenceProvider();
525 PherogramProvider pherogramProvider = readPherogram(pherogramURI); // Must happen before a sequence is added, because it might throw an exception.
526 if (reverseComplemented) {
527 pherogramProvider = new ReverseComplementPherogramProvider(pherogramProvider);
528 }
529
530 // Create sequence:
531 provider.addSequence(name);
532 int id = provider.sequenceIDByName(name);
533
534 // Set edited sequence:
535 Collection<Object> tokens; // First save tokens in a collection to avoid GUI updated for each token.
536 if (editedSequence != null) {
537 tokens = SequenceUtils.stringToTokenList(editedSequence, provider.getTokenSet());
538 }
539 else { // Copy base call sequence into alignment:
540 tokens = new ArrayList<Object>();
541 for (int i = 0; i < pherogramProvider.getSequenceLength(); i++) {
542 tokens.add(provider.getTokenSet().tokenByKeyChar(
543 pherogramProvider.getBaseCall(i).getUpperedBase().charAt(0)));
544 }
545 setDirty();
546 }
547 provider.insertTokensAt(id, 0, tokens);
548
549 // Create pherogram area:
550 PherogramArea pherogramArea = new PherogramArea(getReadsArea().getContentArea(), pherogramProvider);
551
552 // Set shifts:
553 if ((shifts != null) && (shifts.length > 0)) {
554 PherogramAlignmentModel alignmentModel = pherogramArea.getAlignmentModel();
555 for (int i = 0; i < shifts.length; i++) {
556 alignmentModel.addShiftChange(shifts[i].position, shifts[i].shift);
557 }
558 setDirty();
559 }
560
561 // Add pherogram area to GUI:
562 pherogramArea.addMouseListener(new PherogramMouseListener(pherogramURI));
563 getReadsArea().getDataAreas().getSequenceAreas(id).add(pherogramArea);
564
565 // Save source URI:
566 return id;
567 }
568 }