3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.molecular
;
13 import info
.bioinfweb
.commons
.bio
.biojava3
.alignment
.SimpleAlignment
;
14 import info
.bioinfweb
.commons
.bio
.biojava3
.alignment
.template
.Alignment
;
15 import info
.bioinfweb
.commons
.bio
.biojava3
.core
.sequence
.compound
.AlignmentAmbiguityNucleotideCompoundSet
;
16 import info
.bioinfweb
.libralign
.AlignmentArea
;
17 import info
.bioinfweb
.libralign
.AlignmentContentArea
;
18 import info
.bioinfweb
.libralign
.dataarea
.implementations
.ConsensusSequenceArea
;
19 import info
.bioinfweb
.libralign
.dataarea
.implementations
.SequenceIndexArea
;
20 import info
.bioinfweb
.libralign
.dataarea
.implementations
.pherogram
.PherogramArea
;
21 import info
.bioinfweb
.libralign
.pherogram
.BioJavaPherogramProvider
;
22 import info
.bioinfweb
.libralign
.pherogram
.PherogramProvider
;
23 import info
.bioinfweb
.libralign
.pherogram
.ReverseComplementPherogramProvider
;
24 import info
.bioinfweb
.libralign
.sequenceprovider
.SequenceDataProvider
;
25 import info
.bioinfweb
.libralign
.sequenceprovider
.implementations
.BioJavaSequenceDataProvider
;
26 import info
.bioinfweb
.libralign
.sequenceprovider
.implementations
.PackedSequenceDataProvider
;
27 import info
.bioinfweb
.libralign
.sequenceprovider
.tokenset
.BioJavaTokenSet
;
28 import info
.bioinfweb
.libralign
.sequenceprovider
.tokenset
.TokenSet
;
32 import org
.biojava
.bio
.chromatogram
.ChromatogramFactory
;
33 import org
.biojava3
.core
.sequence
.DNASequence
;
34 import org
.biojava3
.core
.sequence
.compound
.DNACompoundSet
;
35 import org
.biojava3
.core
.sequence
.compound
.NucleotideCompound
;
36 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
37 import org
.eclipse
.swt
.SWT
;
38 import org
.eclipse
.swt
.widgets
.Composite
;
39 import org
.eclipse
.ui
.IEditorInput
;
40 import org
.eclipse
.ui
.IEditorSite
;
41 import org
.eclipse
.ui
.PartInitException
;
42 import org
.eclipse
.ui
.part
.EditorPart
;
47 * Editor component to edit a contig alignment used to combine different overlapping pherograms from Sanger sequencing to
48 * a consensus sequence.
50 * The contained GUI components used to edit the alignment come from <a href="http://bioinfweb.info/LibrAlign/">LibrAlign</a>.
56 public class AlignmentEditor
extends EditorPart
{
57 public static final String ID
= "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor";
59 private AlignmentArea alignmentArea
;
62 private AlignmentArea
createAlignmentArea() {
64 AlignmentArea result
= new AlignmentArea();
65 AlignmentContentArea contentArea
= result
.getContentArea();
67 TokenSet
<NucleotideCompound
> tokenSet
= new BioJavaTokenSet
<NucleotideCompound
>(new DNACompoundSet(), true);
68 SequenceDataProvider
<NucleotideCompound
> provider
= new PackedSequenceDataProvider
<NucleotideCompound
>(tokenSet
);
71 contentArea
.getDataAreas().getTopAreas().add(new SequenceIndexArea(contentArea
));
74 // First test sequence with pherogram:
75 provider
.addSequence("Read 1");
76 int id
= provider
.sequenceIDByName("Read 1");
77 BioJavaPherogramProvider pherogramProvider
= new BioJavaPherogramProvider(ChromatogramFactory
.create(
78 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")));
79 //new File("/home/pplitzner/svn/LibrAlign/taxeditor/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR430_JR-P01.ab1")));
81 // Copy base call sequence into alignment:
82 for (int i
= 0; i
< pherogramProvider
.getSequenceLength(); i
++) {
83 provider
.insertTokenAt(id
, i
, tokenSet
.tokenByKeyChar(pherogramProvider
.getBaseCall(i
).getUpperedBase().charAt(0)));
87 PherogramArea pherogramArea
= new PherogramArea(result
.getContentArea(), pherogramProvider
);
88 result
.getContentArea().getDataAreas().getSequenceAreas(id
).add(pherogramArea
);
91 // Second test sequence with pherogram:
92 provider
.addSequence("Read 2");
93 id
= provider
.sequenceIDByName("Read 2");
94 pherogramProvider
= new BioJavaPherogramProvider(ChromatogramFactory
.create(
95 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")));
96 //new File("/home/pplitzner/svn/LibrAlign/taxeditor/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1")));
97 // Copy base call sequence into alignment:
98 for (int i
= 0; i
< pherogramProvider
.getSequenceLength(); i
++) {
99 provider
.insertTokenAt(id
, i
, tokenSet
.tokenByKeyChar(pherogramProvider
.getBaseCall(i
).getUpperedBase().charAt(0)));
103 pherogramArea
= new PherogramArea(result
.getContentArea(), pherogramProvider
);
104 result
.getContentArea().getDataAreas().getSequenceAreas(id
).add(pherogramArea
);
107 contentArea
.setSequenceProvider(provider
, false);
111 catch (Exception e
) {
112 throw new RuntimeException(e
);
118 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
121 public void createPartControl(Composite parent
) {
122 alignmentArea
= createAlignmentArea();
123 Composite alignmentWidget
= alignmentArea
.createSWTWidget(parent
, SWT
.NONE
);
124 //getSite().setSelectionProvider(provider)
129 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
132 public void doSave(IProgressMonitor monitor
) {
133 // TODO Auto-generated method stub
139 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
142 public void doSaveAs() {
143 // TODO Auto-generated method stub
149 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
152 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
159 * @see org.eclipse.ui.part.EditorPart#isDirty()
162 public boolean isDirty() {
163 // TODO Auto-generated method stub
169 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
172 public boolean isSaveAsAllowed() {
173 // TODO Auto-generated method stub
179 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
182 public void setFocus() {
183 //alignmentArea.getToolkitComponent().redistributeHeight();