You can subscribe to this list here.
2002 |
Jan
(52) |
Feb
(157) |
Mar
(185) |
Apr
(207) |
May
(182) |
Jun
(200) |
Jul
(290) |
Aug
(226) |
Sep
(228) |
Oct
(211) |
Nov
(297) |
Dec
(417) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(137) |
Feb
(298) |
Mar
(195) |
Apr
(417) |
May
(266) |
Jun
(130) |
Jul
(134) |
Aug
(206) |
Sep
(146) |
Oct
(171) |
Nov
(208) |
Dec
(231) |
2004 |
Jan
(332) |
Feb
(271) |
Mar
(300) |
Apr
(292) |
May
(207) |
Jun
(226) |
Jul
(67) |
Aug
(111) |
Sep
(90) |
Oct
(165) |
Nov
(219) |
Dec
(141) |
2005 |
Jan
(116) |
Feb
(171) |
Mar
(305) |
Apr
(159) |
May
(143) |
Jun
(165) |
Jul
(104) |
Aug
(276) |
Sep
(244) |
Oct
(166) |
Nov
(176) |
Dec
(105) |
2006 |
Jan
(19) |
Feb
(15) |
Mar
(14) |
Apr
(22) |
May
(12) |
Jun
(151) |
Jul
(41) |
Aug
(11) |
Sep
(21) |
Oct
|
Nov
(1) |
Dec
(50) |
2007 |
Jan
(66) |
Feb
(43) |
Mar
(40) |
Apr
(49) |
May
(29) |
Jun
(7) |
Jul
(13) |
Aug
(70) |
Sep
(41) |
Oct
(42) |
Nov
(10) |
Dec
(26) |
2008 |
Jan
(16) |
Feb
|
Mar
(12) |
Apr
(30) |
May
(26) |
Jun
(12) |
Jul
(10) |
Aug
(13) |
Sep
|
Oct
(2) |
Nov
(6) |
Dec
(4) |
2009 |
Jan
(7) |
Feb
(17) |
Mar
(13) |
Apr
|
May
(2) |
Jun
(46) |
Jul
(15) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2010 |
Jan
(2) |
Feb
(1) |
Mar
(4) |
Apr
|
May
(3) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(11) |
Nov
(2) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
(2) |
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/comparators In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/comparators Added Files: ComparatorBase.java ComparatorFactory.java ComparatorReverse.java ComparatorSeqFeatureDisplayType.java ComparatorSeqFeatureFrame.java ComparatorSeqFeatureLength.java ComparatorSeqFeatureName.java ComparatorSeqFeatureScore.java MultiComparator.java MultiComparatorArrayList.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: ComparatorBase.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; public class ComparatorBase<T> implements Comparator<T> { public int compare(T o1, T o2) { return 0; } } --- NEW FILE: ComparatorFactory.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.datamodel.SeqFeatureI; public class ComparatorFactory { public static enum TYPE { BASE, TYPE, LENGTH, NAME, SCORE, FRAME }; public static Comparator<SeqFeatureI> makeComparatorSeqFeature(TYPE t) { switch (t) { case BASE: return new ComparatorBase<SeqFeatureI>(); case TYPE: return new ComparatorSeqFeatureDisplayType(); case LENGTH: return new ComparatorSeqFeatureLength(); case NAME: return new ComparatorSeqFeatureName(); case SCORE: return new ComparatorSeqFeatureScore(); case FRAME: return new ComparatorSeqFeatureFrame(); } throw new AssertionError("Invalid type: " + t); } public static Comparator<SeqFeatureI> makeReverseComparator(Comparator<SeqFeatureI> c) { return new ComparatorReverse<SeqFeatureI>(c); } } --- NEW FILE: ComparatorReverse.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; public class ComparatorReverse<T> implements Comparator<T> { private Comparator<T> comparator; public ComparatorReverse(Comparator<T> c) { this.comparator = c; } public int compare(T o1, T o2) { return comparator.compare(o2, o1); } } --- NEW FILE: ComparatorSeqFeatureDisplayType.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.config.Config; import apollo.config.FeatureProperty; import apollo.datamodel.SeqFeatureI; public class ComparatorSeqFeatureDisplayType implements Comparator<SeqFeatureI> { public int compare(SeqFeatureI o1, SeqFeatureI o2) { FeatureProperty fp1 = Config.getPropertyScheme() .getFeatureProperty(o1.getTopLevelType()); FeatureProperty fp2 = Config.getPropertyScheme() .getFeatureProperty(o2.getTopLevelType()); return fp1.getDisplayType().compareTo(fp2.getDisplayType()); } } --- NEW FILE: ComparatorSeqFeatureFrame.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; public class ComparatorSeqFeatureFrame implements Comparator<SeqFeatureI> { public int compare(SeqFeatureI o1, SeqFeatureI o2) { return Integer.valueOf(ReadingFrame.valueOf(o1.getFrame()).toInt()) .compareTo(Integer.valueOf(ReadingFrame.valueOf(o2.getFrame()).toInt())); } } --- NEW FILE: ComparatorSeqFeatureLength.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.datamodel.SeqFeatureI; public class ComparatorSeqFeatureLength implements Comparator<SeqFeatureI> { public int compare(SeqFeatureI o1, SeqFeatureI o2) { int result = 0; // the feature lengths int l1 = o1.getHigh() - o1.getLow() + 1; int l2 = o2.getHigh() - o2.getLow() + 1; if (l1 < l2) { result = 1; } else if (l1 > l2) { result = -1; } return result; } } --- NEW FILE: ComparatorSeqFeatureName.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.datamodel.SeqFeatureI; public class ComparatorSeqFeatureName implements Comparator<SeqFeatureI> { public int compare(SeqFeatureI o1, SeqFeatureI o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } } --- NEW FILE: ComparatorSeqFeatureScore.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import apollo.config.Config; import apollo.config.FeatureProperty; import apollo.datamodel.SeqFeatureI; public class ComparatorSeqFeatureScore implements Comparator<SeqFeatureI> { public int compare(SeqFeatureI o1, SeqFeatureI o2) { int result = 0; FeatureProperty fp1 = Config.getPropertyScheme() .getFeatureProperty(o1.getTopLevelType()); FeatureProperty fp2 = Config.getPropertyScheme() .getFeatureProperty(o2.getTopLevelType()); if (!fp1.getDisplayType().equals("Oligo") && !fp2.getDisplayType().equals("Oligo")) { double s1 = o1.getScore(); double s2 = o2.getScore(); String n1 = o1.getName(); String n2 = o2.getName(); int j1 = 1; } if (o1.getScore() < o2.getScore()) { result = 1; } else if (o1.getScore() > o2.getScore()) { result = -1; } return result; } } --- NEW FILE: MultiComparator.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.Comparator; import java.util.List; import apollo.datamodel.SeqFeatureI; public interface MultiComparator <T> extends Comparator<T>, List<Comparator<T>>{ } --- NEW FILE: MultiComparatorArrayList.java --- package apollo.gui.detailviewers.sequencealigner.comparators; import java.util.LinkedList; import java.util.Comparator; import java.util.Iterator; import apollo.datamodel.SeqFeatureI; public class MultiComparatorArrayList<T> extends LinkedList<Comparator<T>> implements MultiComparator <T>{ public MultiComparatorArrayList() { super(); this.add(new ComparatorBase<T>()); } public boolean add(Comparator<T> o) { this.addFirst(o); if (this.size() > 4) { this.removeLast(); } return true; } public int compare(T o1, T o2) { int result = 0; Iterator<Comparator<T>> itr = this.iterator(); while(itr.hasNext() && result == 0) { Comparator<T> c = itr.next(); result = c.compare(o1, o2); } return result; } } |
From: elee <gk...@us...> - 2009-06-02 16:50:28
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/AAPanel In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/AAPanel Added Files: AAMultiSequenceAlignerPanel.java ReferencePanel.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AAMultiSequenceAlignerPanel.java --- package apollo.gui.detailviewers.sequencealigner.AAPanel; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.swing.AbstractAction; [...962 lines suppressed...] @Override public MultiFilter getResultFilter() { return this.resultFilter; } @Override public void clearAnnotations() { this.annotations.clear(); this.annotationPanel.clear(); } @Override public AbstractScrollablePanel getAddressComponent() { return this.addressComponent; } } --- NEW FILE: ReferencePanel.java --- package apollo.gui.detailviewers.sequencealigner.AAPanel; import java.awt.Color; import java.awt.Dimension; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.AbstractTierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder; import apollo.gui.detailviewers.sequencealigner.MultiTierPanel; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.ReferenceFactoryI; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.Tier; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierPanel; import apollo.gui.detailviewers.sequencealigner.renderers.AminoAcidBaseRenderer; import apollo.gui.detailviewers.sequencealigner.renderers.AminoAcidRenderer; public class ReferencePanel extends MultiTierPanel { private ReferenceFactoryI referenceFactory; private MultiTierPanel annotationPanel; private Color dnaColor; public ReferencePanel(ReferenceFactoryI referenceFactory, MultiTierPanel annotationPanel) { //Orientation orientation, Strand strand, ReadingFrame frame) { super(FeaturePlaceFinder.Type.COMPACT); this.annotationPanel = annotationPanel; this.dnaColor = Color.DARK_GRAY; Orientation orientation = annotationPanel.getOrientation(); Strand strand = annotationPanel.getStrand(); ReadingFrame frame = annotationPanel.getReadingFrame(); this.referenceFactory = referenceFactory; // The AA Reference for the current strand SequenceI referenceAA = referenceFactory.getReference(strand, frame); // Reference for the current frame AminoAcidRenderer aar = new AminoAcidRenderer(frame); TierI tier = new Tier(referenceAA, strand, frame); AbstractTierPanel panel = new TierPanel(tier, orientation, aar); addPanel(panel); // The following three tiers show want bases make up the reference AA SequenceI referenceDNA = referenceFactory.getReference(strand); AminoAcidBaseRenderer aabr = new AminoAcidBaseRenderer(frame.getIndex() + 0, orientation); aabr.setBackground(dnaColor); tier = new Tier(referenceDNA, strand, ReadingFrame.NONE); panel = new TierPanel(tier, orientation, aabr); addPanel(panel); aabr = new AminoAcidBaseRenderer(frame.getIndex() + 1, orientation); aabr.setBackground(dnaColor); tier = new Tier(referenceDNA, strand, ReadingFrame.NONE); panel = new TierPanel(tier, orientation, aabr); addPanel(panel); aabr = new AminoAcidBaseRenderer(frame.getIndex() + 2, orientation); aabr.setBackground(dnaColor); tier = new Tier(referenceDNA, strand, ReadingFrame.NONE); panel = new TierPanel(tier, orientation, aabr); addPanel(panel); //this.setReadingFrame(frame); this.reformat(false); } public void reformat(boolean isRecursive) { Orientation orientation = annotationPanel.getOrientation(); Strand strand = annotationPanel.getStrand(); ReadingFrame frame = annotationPanel.getReadingFrame(); // The AA Reference for the current strand SequenceI referenceAA = referenceFactory.getReference(strand, frame); // Reference for the current frame AbstractTierPanel panel = getPanel(0); panel.getTier().setStrand(strand); panel.getTier().setReference(referenceAA); panel.setOrientation(orientation); panel.reformat(true); panel.setPreferredSize(new Dimension(referenceAA.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); // The following three tiers show want bases make up the reference AA SequenceI referenceDNA = referenceFactory.getReference(getStrand()); AminoAcidBaseRenderer aabr = new AminoAcidBaseRenderer(frame.getIndex() + 0, orientation); aabr.setBackground(dnaColor); panel = getPanel(1); panel.setRenderer(aabr); panel.getTier().setStrand(strand); panel.getTier().setReference(referenceDNA); panel.setOrientation(orientation); panel.reformat(true); panel.setPreferredSize(new Dimension(referenceAA.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); panel = getPanel(2); aabr = new AminoAcidBaseRenderer(frame.getIndex() + 1, orientation); aabr.setBackground(dnaColor); panel.setRenderer(aabr); panel.getTier().setStrand(strand); panel.getTier().setReference(referenceDNA); panel.reformat(true); panel.setOrientation(orientation); panel.setPreferredSize(new Dimension(referenceAA.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); panel = getPanel(3); aabr = new AminoAcidBaseRenderer(frame.getIndex() + 2, orientation); aabr.setBackground(dnaColor); panel.setRenderer(aabr); panel.getTier().setStrand(strand); panel.getTier().setReference(referenceDNA); panel.setOrientation(orientation); panel.reformat(true); panel.setPreferredSize(new Dimension(referenceAA.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); super.reformat(isRecursive); } } |
From: elee <gk...@us...> - 2009-06-02 16:50:27
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/overview In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/overview Added Files: IntervalComponent.java Overview.java TranscriptOverview.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: IntervalComponent.java --- package apollo.gui.detailviewers.sequencealigner.overview; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.util.Comparator; import java.util.HashMap; import java.util.Set; import java.util.TreeMap; import javax.swing.JComponent; import javax.swing.JFrame; import apollo.datamodel.AnnotatedFeatureI; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.util.interval.Interval; /** * This is the class which draws intervals. * Assumes intervals can be uniquely identified by their start position. */ public class IntervalComponent extends JComponent { private static final long serialVersionUID = -8127066813604422951L; public enum Valignment { TOP, BOTTOM, CENTER }; private enum Directions { FORWARD, REVERSE }; private TreeMap<Interval, Integer> intervalHeight; private HashMap<Interval, Color> colors; private Directions direction; private int length; private Valignment vAlignment; private Color primaryColor; /** * Empty Constructor */ public IntervalComponent() { intervalHeight = new TreeMap<Interval, Integer>(); colors = new HashMap<Interval, Color>(); direction = Directions.FORWARD; length = 0; vAlignment = Valignment.CENTER; primaryColor = Color.cyan; } public void clear() { intervalHeight.clear(); colors.clear(); } /** * Paints the overview for this result set. */ public void paint(Graphics g) { super.paint(g); Set<Interval> intervals = intervalHeight.keySet(); double scalingFactor = (double) length / (double) this.getSize().width; for (Interval i : intervals){ int height = calculateHeight(i); int width = calculateWidth(i, scalingFactor); int y = calculateVerticalPosition(i); int x = calculateHorizontalPosition(i, scalingFactor); if (height > 0) { g.setColor(getColor(i)); g.fillRect(x, y, width, height); } x += width; } } /** * Associates the specified height with the specified Interval in this * component. If this component previously contained a mapping for the given * Interval, the old height is replaced. * * @param i the interval to be added * @param height the height of the given interval * @return previous height associated with specified Interval, or null * if there was no mapping for this Interval. */ public Integer putInterval(Interval i, int height) { return intervalHeight.put(i, new Integer(height)); } /** * Removes the mapping for this Interval from this component if present. * @param i the interval to be removed. * @return previous count associated with specified Interval, or null * if there was no mapping for this Interval. */ public Integer remove(Interval i) { return intervalHeight.remove(i); } /** true if the component will be rendered forwards false otherwise */ public boolean isForward() { return direction == Directions.FORWARD; } /** Sets the direction of this component to be forward */ public void setForward() { direction = Directions.FORWARD; } /** Sets the direction of this component to be reverse */ public void setReverse() { direction = Directions.REVERSE; } public void switchDirection() { if (direction == Directions.FORWARD) direction = Directions.REVERSE; else direction = Directions.FORWARD; } /** Gets the length of this component */ public double getLength() { return length; } /** Sets the scaling factor for this component */ public void setLength(int l) { length = l; } public Color getColor(Interval i) { Color result = colors.get(i); if (result == null) { result = primaryColor; } return result; } public void setColors(Interval i, Color c) { colors.put(i, c); } public Color getPrimaryColor() { return primaryColor; } public void setPrimaryColor(Color primaryColor) { this.primaryColor = primaryColor; } /** Private class used to compare intervals. * Assumes intervals can be uniquely identified by their start position. */ /* private class IntervalComparator implements Comparator<Interval> { public int compare(Interval i0, Interval i1) { return i0.getStart() - i1.getStart(); } }*/ /** * Calculates the pixel height for a given Interval * @param i the interval * @return the pixel height for the given Interval */ private int calculateHeight(Interval i) { int result = intervalHeight.get(i).intValue(); if (result < 0) { result = 0; } if (result > this.getSize().height) { result = this.getSize().height; } return result; } /** * Calculates the pixel width for the given interval * @param i the interval * @param sf the scaling factor for this interval * @return the pixel width for the given interval */ private int calculateWidth(Interval i, double sf) { int length = i.getHigh() - i.getLow(); int width = (int) Math.floor((double)length / (double) sf); if (width < 1) width = 1; return width; } private int calculateVerticalPosition(Interval i){ // TOP int result = 0; int height = this.calculateHeight(i); if (vAlignment == Valignment.CENTER) { result = (this.getHeight() - height) / 2; } if (vAlignment == Valignment.BOTTOM) { result = this.getHeight() - height; } return result; } /** * Calculates the pixel position for the start given an interval. * @param i the interval * @param sf the scaling factor for this interval * @return the pixel position for the start */ private int calculateHorizontalPosition(Interval i, double sf) { int result = i.getLow(); if (direction == Directions.REVERSE) { result = length - i.getHigh(); } result = (int) Math.floor((double)result/ (double) sf); return result; } public static void main(String [ ] args) { Dimension d = new Dimension(500, 300); int length = 200; JFrame f = new JFrame("TopLevelDemo"); IntervalComponent o = new IntervalComponent(); o.setPreferredSize(d); o.setSize(d); o.setLength(length); o.setVisible(true); for (int x = 0; x < 150; x += 20) { Interval i = new Interval(x, x+20); if (x%40 == 0) o.putInterval(i, 20); // else //o.putInterval(i, 2); } f.add(o); f.setPreferredSize(d); f.pack(); f.setVisible(true); } } --- NEW FILE: Overview.java --- package apollo.gui.detailviewers.sequencealigner.overview; import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.Vector; import javax.swing.JComponent; import javax.swing.event.MouseInputAdapter; import org.bdgp.swing.FastTranslatedGraphics; import org.bdgp.util.RangeHash; import apollo.datamodel.ExonI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceEdit; import apollo.datamodel.SequenceI; import apollo.datamodel.Transcript; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.SequenceType; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.TierPanel; import apollo.gui.detailviewers.sequencealigner.TierPanelI; import apollo.gui.detailviewers.sequencealigner.AAPanel.AAMultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.filters.FilterFactory; import apollo.gui.detailviewers.sequencealigner.filters.MultiFilter; import apollo.gui.detailviewers.sequencealigner.filters.MultiFilterAnd; import apollo.gui.drawable.DrawableUtil; import apollo.util.interval.Interval; import apollo.util.interval.IntervalTree; /** * This draws the clickable transcript diagram at the bottom EDE */ public class Overview extends JComponent { //Color [][] colorList; private IntervalComponent top; //private TranscriptOverview mid; private IntervalComponent bottom; private MultiSequenceAlignerPanel editorPanel; private Transcript transcript; private int tier; private Strand strand; private boolean isForward = true; private RangeHash rh = new RangeHash(); //int translationStart = -1; //int translationEnd = -1; private boolean drawIntrons = true; private int margin = 20; // horizontal? vertical? both? private int barHeight = 20; private int resultInflection = 25; private Color shiftColor = apollo.config.Config.getStyle().getSeqErrorColor(); /** * Constructor * @param editorPanel */ public Overview(MultiSequenceAlignerPanel editorPanel) { this.editorPanel = editorPanel; //colorList = editorPanel.getColorArray(); this.top = new IntervalComponent(); this.bottom = new IntervalComponent(); this.strand = editorPanel.getStrand(); setPreferredSize(new Dimension(300,barHeight+margin*2));// does this make sense? setForeground(Color.white); NavClickListener listener = new NavClickListener(); addMouseListener(listener); addMouseMotionListener(listener); } /** * Determine whether or not to draw the introns in the overview * @param drawIntrons should be true if introns should be drawn false othewise * * NOTE: not sure if this is still working */ public void setDrawIntrons(boolean drawIntrons) { this.drawIntrons = drawIntrons; repaint(); } /** * Gets the current value of drawIntrons * @return */ public boolean getDrawIntrons() { return drawIntrons; } /** * Sets the new transcript as the main feature in the overview. * @param transcript * * Calls updateState(), repaint() */ public void setTranscript(Transcript transcript) { if (transcript != null && transcript != this.transcript) { this.transcript = transcript; this.strand = Strand.valueOf(transcript.getStrand()); updateState(); this.repaint(); } /* The exons should already be sorted */ //this.tier = tier; } public Transcript getTranscript() { return this.transcript; } /** * Updates the two result components to reflect the current state of the * overview */ public void updateState() { Orientation o = editorPanel.getAnnotationPanel().getOrientation(); isForward = o == Orientation.FIVE_TO_THREE; if (Strand.valueOf(transcript.getStrand()) == Strand.REVERSE) isForward = !isForward; if (Strand.valueOf(transcript.getStrand()) != editorPanel.getStrand()) isForward = !isForward; updateResult(top, Strand.FORWARD); updateResult(bottom, Strand.REVERSE); } /** * Updates an interval component so that it displays the results within * the bounds of the currently selected transcirpt on a particular strand. * * @param result the component to be updated * @param strand the strand from which the results should be selected */ public void updateResult(IntervalComponent result, Strand strand) { if (isForward) { result.setForward(); } else { result.setReverse(); } MultiFilter<SeqFeatureI> filters = new MultiFilterAnd(); filters.addAll(editorPanel.getResultFilter()); filters.add( FilterFactory.makeFilter(SequenceType.valueOf(editorPanel.getType()))); filters.add(FilterFactory.makeFilter(strand)); SeqFeatureI resultSet = this.editorPanel.getCurationState().getCurationSet() .getResults().getFeatSetForStrand(strand.toInt()); Set<SeqFeatureI> results = MultiSequenceAlignerPanel.getResults(resultSet, filters); /* Set<SeqFeatureI> results = MultiSequenceAlignerPanel.getResults(editorPanel.getType(), resultSet); */ result.setLength(transcript.getHigh() - transcript.getLow()); result.clear(); // NOTE: this probably produces too many points of interest, can probably // be done better TreeSet<Integer> poi = new TreeSet<Integer>(); // points of interest IntervalTree intervals = new IntervalTree(); int offset = transcript.getLow(); for (SeqFeatureI feature : results) { if (transcript.getLow() <= feature.getHigh() && transcript.getHigh() >= feature.getLow()) { int low = Math.max(0, feature.getLow() - offset); int high = Math.min(transcript.getHigh() - offset, feature.getHigh() - offset) - 1; Interval i = new Interval(low, high); intervals.insert(i); poi.add(low); poi.add(high); poi.add(high+1); } } Iterator<Integer> iter = poi.iterator(); Integer low = null; Integer high = null; if (iter.hasNext()) { low = iter.next(); } while (iter.hasNext()) { high = iter.next(); Interval i = new Interval(low, high-1); List<Interval> overlaps = intervals.searchAll(i); int size = overlaps.size(); int height = (int) Math.min(size, .6*margin); if (size > resultInflection) { height += (int) Math.log(size-resultInflection); } result.putInterval(new Interval(low, high), height); low = high; } } public void validate() { Dimension size = this.getSize(); Dimension third = new Dimension(size.width - 2*margin, size.height/3); top.setPreferredSize(third); top.setSize(third); bottom.setPreferredSize(third); bottom.setSize(third); super.validate(); } // I think this gets repainted every time the window moves... public void paint(Graphics g) { super.paint(g); // todo... create a exon component that will paint its self // then create a transcript component that is made up of exons // use those to create draw this... // mabe i can use some the code that draws the transcripts on the main // apollo window? g.setFont(getFont()); if (transcript == null) return; rh.removeAll(); // Translation start range int translationStart = transcript.getTranslationStart(); int laststart_base = transcript.getPositionFrom(translationStart, 2); // Translation end range int translationEnd = transcript.getTranslationEnd(); int laststop_base = transcript.getLastBaseOfStopCodon(); // What are these? int readthrough_pos = transcript.readThroughStopPosition(); int lastreadon_base = transcript.getPositionFrom(readthrough_pos, 2); int topDistance = (getSize().height - barHeight) / 2; java.util.Vector exons = transcript.getExons(); int exon_count = exons.size(); int featureWidth; // if we want to see the introns then set featureWidth to the transcript // length and draw a rectangle. if (drawIntrons) { featureWidth = (int) transcript.length(); // Get the indicator color for the panel holding this overview g.setColor(editorPanel.getIndicatorColor()); // Draw the line in the middle starting from the left margin g.fillRect(margin, (getSize().height - 2) / 2, getSize().width - margin*2,// - 1, 3); } else { featureWidth = 0; for(int i=0; i < exon_count; i++) { SeqFeatureI feature = (SeqFeatureI) exons.elementAt(i); featureWidth += (int) feature.length(); } } double scaling_factor = ((double) featureWidth / (double) (getSize().width - margin*2)); int x = margin; // Loop through exons for(int i=0; i < exon_count; i++) { ExonI exon = null; if (isForward) { exon = transcript.getStrand() == 1 ? transcript.getExonAt(i) : transcript.getExonAt(exon_count-i-1); } else { exon = transcript.getStrand() == 1 ? transcript.getExonAt(exon_count-i-1) : transcript.getExonAt(i); } int low = (int) exon.getLow(); int high = (int) exon.getHigh(); //int width = (int) Math.floor(exon.length() / scaling_factor); int width = (int) Math.round(exon.length() / scaling_factor); if (width < 1) width = 1; // int transcriptColorIndex = (editorPanel.getRangeIndex(tier, // lowPos, // highPos) // % colorList.length); // int exonColorIndex = (editorPanel.getExonRangeIndex(tier, // lowPos, // highPos) // % colorList[transcriptColorIndex].length); // g.setColor(colorList[transcriptColorIndex][exonColorIndex]); g.setColor(Color.blue); //TODO: change? int offset = 0; if (isForward) { offset = transcript.getStrand() == 1 ? (int) Math.round( Math.abs(transcript.getStart()-exon.getStart())/scaling_factor) : (int) Math.round( Math.abs(transcript.getEnd()-exon.getEnd())/scaling_factor); } else { offset = transcript.getStrand() == 1 ? (int) Math.round( Math.abs(transcript.getEnd()-exon.getEnd())/scaling_factor) : (int) Math.round( Math.abs(transcript.getStart()-exon.getStart())/scaling_factor); } x = margin+offset; rh.put(x, x+width-1, exon); g.fillRect(x, topDistance, width, barHeight+1); // paint the codons paintCodon (g, exon, translationStart, laststart_base, low, high, DrawableUtil.getStartCodonColor(transcript), x, topDistance, scaling_factor); paintCodon (g, exon, translationEnd, laststop_base, low, high, Color.red, x, topDistance, scaling_factor); paintCodon (g, exon, readthrough_pos, lastreadon_base, low, high, Color.pink, x, topDistance, scaling_factor); // If exon is coding draw in frame number - what is the first frame?X paintFrame(g, exon, low, high, translationStart, laststop_base, x, topDistance, scaling_factor); } // end of exon loop FastTranslatedGraphics transG = new FastTranslatedGraphics(g); transG.translateAbsolute(margin, 0); top.paint(transG); transG.translateAbsolute(margin, 2*bottom.getSize().height); bottom.paint(transG); int baseStart = editorPanel.getVisibleBase(); int baseCount = editorPanel.getVisibleBaseCount(); /* TierPanelI tierPanel = editorPanel.getAnnotationPanel().getModelTierPanel(); */ int baseOffset = 0; if (isForward) { baseOffset = transcript.getStrand() == 1 ? baseStart - transcript.getStart() : baseStart - transcript.getEnd(); } else { baseOffset = transcript.getStrand() == 1 ? transcript.getEnd() - baseStart : transcript.getStart() - baseStart; } int pixelOffset = (int) ((double) baseOffset / scaling_factor); int basePixelStart = margin+pixelOffset; int basePixelCount = (int) ((double) baseCount / (double) scaling_factor); // g.setColor(Color.yellow); // Box that goes over exon diagram at the bottom to show which region // you're seeing in the detailed view g.setColor(Color.black); //TODO config g.drawRect(basePixelStart, topDistance-4, basePixelCount, barHeight+8); // To make a two-pixel-wide rectangle, draw a one-pixel-bigger rectangle // around the first one g.drawRect(basePixelStart-1, topDistance-5, basePixelCount+2, barHeight+10); } private void paintCodon (Graphics g, ExonI exon, int first_base, int last_base, int low, int high, Color codon_color, int x, int topDistance, double scaling_factor) { int expected_last = first_base + (2 * exon.getStrand()); if (first_base > 0) { if (first_base >= low && first_base <= high) { g.setColor(codon_color); // account for stop codons that span exon boundaries int codon_width = (last_base != expected_last ? Math.abs(exon.getEnd() - first_base) + 1 : 3); int offset = 0; if (isForward) { offset = exon.getStrand() == 1 ? (int) (Math.abs(exon.getStart() - first_base) /scaling_factor) : (int) (Math.abs(exon.getEnd() - first_base) /scaling_factor); } else { offset = exon.getStrand() == 1 ? (int) (Math.abs(exon.getEnd() - first_base) /scaling_factor) : (int) (Math.abs(exon.getStart() - first_base) /scaling_factor); } int rect_width = (int) (((double) codon_width) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x + offset, topDistance, rect_width, barHeight+1); } if (last_base != expected_last && last_base >= low && last_base <= high) { g.setColor(codon_color); // account for stop codons that span exon boundaries int codon_width = Math.abs(last_base - exon.getStart()) + 1; int rect_width = (int) (((double) codon_width) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x, topDistance, rect_width, barHeight+1); } } } private void paintBase (Graphics g, ExonI exon, int base_pos, int low, int high, Color base_color, int x, int topDistance, double scaling_factor) { if (base_pos > 0) { if (base_pos >= low && base_pos <= high) { g.setColor(base_color); // account for stop codons that span exon boundaries int offset = (int) (Math.abs(exon.getStart() - base_pos) / scaling_factor); int rect_width = (int) (((double) 1) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x + offset, topDistance, rect_width, barHeight+1); } } } //draws the frame number for this exon? private void paintFrame(Graphics g, ExonI exon, int low, int high, int translationStart, int laststop_base, int exon_x, int topDistance, double scaling_factor) { boolean coding = exon.containsCoding(); int frame = exon.getFrame(); FontMetrics metrics = getFontMetrics(getFont()); SequenceEdit [] edit_list = exon.buildEditList(); int edits = (edit_list != null ? edit_list.length : 0); int x = exon_x; int prev_pos; if (exon.contains(translationStart)) { prev_pos = translationStart; int length = Math.abs(exon.getStart() - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; x += width; } else { prev_pos = exon.getStart(); x = exon_x; } int last_pos = (exon.contains(laststop_base) ? laststop_base : exon.getEnd()); for (int i = 0; i < edits; i++) { SequenceEdit edit = edit_list[i]; int pos = edit.getPosition(); paintBase(g, exon, pos, low, high, shiftColor, // was Color.yellow exon_x, topDistance, scaling_factor); if (coding) { g.setColor(getForeground()); String drawMe = ""+(frame); int strWidth = metrics.stringWidth(drawMe); int length = Math.abs(pos - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; int fontx = x + width / 2 - (strWidth / 2); int fonty = topDistance + barHeight / 2 + getFont().getSize() / 2; g.drawString(drawMe, fontx, fonty); x += width; prev_pos = pos; if (edit.getEditType().equals(SequenceI.DELETION)) { frame = (frame == 3 ? 1 : frame - 1); } if (edit.getEditType().equals(SequenceI.INSERTION)) { frame = (frame == 1 ? 3 : frame + 1); } } } if (coding) { g.setColor(getForeground()); String drawMe = ""+(frame); int strWidth = metrics.stringWidth(drawMe); int length = Math.abs(last_pos - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; int fontx = x + width / 2 - (strWidth / 2); int fonty = topDistance + barHeight / 2 + getFont().getSize() / 2; g.drawString(drawMe, fontx, fonty); x += width; } } private class NavClickListener extends MouseInputAdapter { public void mouseMoved(MouseEvent e) {} public void mouseClicked(MouseEvent e) { if (transcript != null) { double [] range = rh.getInterval(e.getX()); SeqFeatureI feature = (SeqFeatureI) rh.get(e.getX()); int basepair; //if (range == null || feature == null) { double offset = e.getX() - margin; double scale = ((double) transcript.length()) / ((double) getSize().width - margin*2); basepair = 0; if (isForward) { basepair = transcript.getStrand() == 1 ? (int) (transcript.getStart() + (transcript.getStrand() * offset * scale)) : (int) (transcript.getEnd() - (transcript.getStrand() * offset * scale)); } else { basepair = transcript.getStrand() == 1 ? (int) (transcript.getEnd() - (transcript.getStrand() * offset * scale)) : (int) (transcript.getStart() + (transcript.getStrand() * offset * scale)); } editorPanel.scrollToBase(basepair); // Switch to the frame of the exon that is being scrolled to if (editorPanel.getType() == SequenceI.AA && editorPanel instanceof AAMultiSequenceAlignerPanel) { AAMultiSequenceAlignerPanel panel = (AAMultiSequenceAlignerPanel) editorPanel; Vector exons = transcript.getExons(); Iterator iter = exons.iterator(); while (iter.hasNext()) { ExonI exon = (ExonI) iter.next(); if (exon.getLow() <= basepair && exon.getHigh() >= basepair && ReadingFrame.valueOf(exon.getFrame()) != ReadingFrame.NONE && ReadingFrame.valueOf(exon.getFrame()) != panel.getFrame()) { panel.setFrame(ReadingFrame.valueOf(exon.getFrame())); panel.repaint(); } } } } } } } --- NEW FILE: TranscriptOverview.java --- package apollo.gui.detailviewers.sequencealigner.overview; import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; import javax.swing.JComponent; import apollo.datamodel.ExonI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceEdit; import apollo.datamodel.SequenceI; import apollo.datamodel.Transcript; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.drawable.DrawableUtil; public class TranscriptOverview extends JComponent { private Transcript transcript; private boolean drawIntrons; private IntervalComponent tran; int barHeight = 10; Color shiftColor = Color.black; public void paint(Graphics g) { super.paint(g); /* g.setFont(getFont()); if (transcript == null) return; rh.removeAll(); // int length = editorPanel. // getSequenceForTier(editorPanel.getSelectedTier()).getLength(); translationStart = transcript.getTranslationStart(); int laststart_base = transcript.getPositionFrom(translationStart, 2); translationEnd = transcript.getTranslationEnd(); int laststop_base = transcript.getLastBaseOfStopCodon(); int readthrough_pos = transcript.readThroughStopPosition(); int lastreadon_base = transcript.getPositionFrom(readthrough_pos, 2); int topDistance = (getSize().height - barHeight) / 2; java.util.Vector exons = transcript.getExons(); int exon_count = exons.size(); int featureWidth; // if we want to see the introns then set featureWidth to the transcript // length and draw a rectangle. if (drawIntrons) { featureWidth = (int) transcript.length(); int lowPos = editorPanel.getAnnotationPanel() .basePairToPosition((int)transcript.getLow()); int highPos = editorPanel.getAnnotationPanel() .basePairToPosition((int)transcript.getHigh()); //int lineColorIndex = (editorPanel.getRangeIndex(tier, // lowPos, // highPos) // % colorList.length); //g.setColor(colorList[lineColorIndex][0]); g.setColor(editorPanel.getIndicatorColor()); g.fillRect(margin, (getSize().height - 2) / 2, getSize().width - margin*2 - 1, 3); } else { featureWidth = 0; for(int i=0; i < exon_count; i++) { SeqFeatureI feature = (SeqFeatureI) exons.elementAt(i); featureWidth += (int) feature.length(); } } double scaling_factor = ((double) featureWidth / (double) (getSize().width - margin*2)); int x = margin; // Loop through exons for(int i=0; i < exon_count; i++) { ExonI exon = transcript.getExonAt(i); int low = (int) exon.getLow(); int high = (int) exon.getHigh(); int lowPos = editorPanel.getAnnotationPanel().basePairToPosition(low); int highPos = editorPanel.getAnnotationPanel().basePairToPosition(high); int width = (int) Math.floor(exon.length() / scaling_factor); if (width < 1) width = 1; // int transcriptColorIndex = (editorPanel.getRangeIndex(tier, // lowPos, // highPos) // % colorList.length); // int exonColorIndex = (editorPanel.getExonRangeIndex(tier, // lowPos, // highPos) // % colorList[transcriptColorIndex].length); // g.setColor(colorList[transcriptColorIndex][exonColorIndex]); g.setColor(Color.blue); //TODO: change int drawX = x; rh.put(drawX, drawX+width-1, exon); g.fillRect(drawX, topDistance, width, barHeight+1); // paint the codons paintCodon (g, exon, translationStart, laststart_base, low, high, DrawableUtil.getStartCodonColor(transcript), x, topDistance, scaling_factor); paintCodon (g, exon, translationEnd, laststop_base, low, high, Color.red, x, topDistance, scaling_factor); paintCodon (g, exon, readthrough_pos, lastreadon_base, low, high, Color.pink, x, topDistance, scaling_factor); // If exon is coding draw in frame number - what is the first frame?X paintFrame(g, exon, low, high, translationStart, laststop_base, x, topDistance, scaling_factor); // increment x x += width; if (drawIntrons && (i + 1) < exon_count) { ExonI nextExon = transcript.getExonAt (i+1); int intron_len = (int) (exon.getStrand() == 1 ? (nextExon.getLow() - high + 1) : (low - nextExon.getHigh() + 1)); x += (intron_len / scaling_factor); } } // end of exon loop int baseStart = editorPanel.getVisibleBase(); int baseCount = editorPanel.getVisibleBaseCount(); int baseOffset = baseStart - (int) transcript.getStart(); if (editorPanel.getStrand() == Strand.REVERSE) baseOffset = (int) transcript.getStart() - baseStart; int pixelOffset = (int) ((double) baseOffset / scaling_factor); int basePixelStart = margin+pixelOffset; int basePixelCount = (int) ((double) baseCount / (double) scaling_factor); // g.setColor(Color.yellow); // Box that goes over exon diagram at the bottom to show which region // you're seeing in the detailed view g.setColor(Color.black); //TODO config g.drawRect(basePixelStart, topDistance-4, basePixelCount, barHeight+8); // To make a two-pixel-wide rectangle, draw a one-pixel-bigger rectangle // around the first one g.drawRect(basePixelStart-1, topDistance-5, basePixelCount+2, barHeight+10);*/ } public boolean getDrawIntrons() { return drawIntrons; } public void setDrawIntrons(boolean drawIntrons) { this.drawIntrons = drawIntrons; repaint(); } private void paintCodon (Graphics g, ExonI exon, int first_base, int last_base, int low, int high, Color codon_color, int x, int topDistance, double scaling_factor) { int expected_last = first_base + (2 * exon.getStrand()); if (first_base > 0) { if (first_base >= low && first_base <= high) { g.setColor(codon_color); // account for stop codons that span exon boundaries int codon_width = (last_base != expected_last ? Math.abs(exon.getEnd() - first_base) + 1 : 3); int offset = (int) (Math.abs(exon.getStart() - first_base) / scaling_factor); int rect_width = (int) (((double) codon_width) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x + offset, topDistance, rect_width, barHeight+1); } if (last_base != expected_last && last_base >= low && last_base <= high) { g.setColor(codon_color); // account for stop codons that span exon boundaries int codon_width = Math.abs(last_base - exon.getStart()) + 1; int rect_width = (int) (((double) codon_width) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x, topDistance, rect_width, barHeight+1); } } } private void paintBase (Graphics g, ExonI exon, int base_pos, int low, int high, Color base_color, int x, int topDistance, double scaling_factor) { if (base_pos > 0) { if (base_pos >= low && base_pos <= high) { g.setColor(base_color); // account for stop codons that span exon boundaries int offset = (int) (Math.abs(exon.getStart() - base_pos) / scaling_factor); int rect_width = (int) (((double) 1) / scaling_factor); if (rect_width < 1) rect_width = 1; g.fillRect(x + offset, topDistance, rect_width, barHeight+1); } } } //draws the frame number for this exon? private void paintFrame(Graphics g, ExonI exon, int low, int high, int translationStart, int laststop_base, int exon_x, int topDistance, double scaling_factor) { boolean coding = exon.containsCoding(); int frame = exon.getFrame(); FontMetrics metrics = getFontMetrics(getFont()); SequenceEdit [] edit_list = exon.buildEditList(); int edits = (edit_list != null ? edit_list.length : 0); int x = exon_x; int prev_pos; if (exon.contains(translationStart)) { prev_pos = translationStart; int length = Math.abs(exon.getStart() - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; x += width; } else { prev_pos = exon.getStart(); x = exon_x; } int last_pos = (exon.contains(laststop_base) ? laststop_base : exon.getEnd()); for (int i = 0; i < edits; i++) { SequenceEdit edit = edit_list[i]; int pos = edit.getPosition(); paintBase(g, exon, pos, low, high, shiftColor, // was Color.yellow exon_x, topDistance, scaling_factor); if (coding) { g.setColor(getForeground()); String drawMe = ""+(frame); int strWidth = metrics.stringWidth(drawMe); int length = Math.abs(pos - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; int fontx = x + width / 2 - (strWidth / 2); int fonty = topDistance + barHeight / 2 + getFont().getSize() / 2; g.drawString(drawMe, fontx, fonty); x += width; prev_pos = pos; if (edit.getEditType().equals(SequenceI.DELETION)) { frame = (frame == 3 ? 1 : frame - 1); } if (edit.getEditType().equals(SequenceI.INSERTION)) { frame = (frame == 1 ? 3 : frame + 1); } } } if (coding) { g.setColor(getForeground()); String drawMe = ""+(frame); int strWidth = metrics.stringWidth(drawMe); int length = Math.abs(last_pos - prev_pos) + 1; int width = (int) Math.floor(length / scaling_factor); if (width < 1) width = 1; int fontx = x + width / 2 - (strWidth / 2); int fonty = topDistance + barHeight / 2 + getFont().getSize() / 2; g.drawString(drawMe, fontx, fonty); x += width; } } } |
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/DNAPanel In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/DNAPanel Added Files: AminoAcidPanel.java DNAMultiSequenceAlignerPanel.java HomogeneousPanel.java ReferencePanel.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AminoAcidPanel.java --- package apollo.gui.detailviewers.sequencealigner.DNAPanel; import java.awt.Dimension; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.AbstractTierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder; import apollo.gui.detailviewers.sequencealigner.MultiTierPanel; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.ReferenceFactoryI; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.Tier; import apollo.gui.detailviewers.sequencealigner.TierFactoryI; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder.Type; import apollo.gui.detailviewers.sequencealigner.renderers.AminoAcidRendererSpaced; class AminoAcidPanel extends MultiTierPanel { private ReferenceFactoryI referenceFactory; public AminoAcidPanel(ReferenceFactoryI referenceFactory, Orientation orientation, Strand strand) { super(FeaturePlaceFinder.Type.COMPACT); this.referenceFactory = referenceFactory; /* The DNA Reference for the current strand */ SequenceI reference = referenceFactory.getReference(strand, ReadingFrame.NONE); /* Frame 1 */ AminoAcidRendererSpaced aar = new AminoAcidRendererSpaced(0); TierI tier1 = new Tier( referenceFactory.getReference(strand, ReadingFrame.ONE), strand, ReadingFrame.ONE); AbstractTierPanel tierPanel1 = new TierPanel(tier1, orientation, aar); /* Frame 2 */ aar = new AminoAcidRendererSpaced(1); TierI tier2 = new Tier( referenceFactory.getReference(strand, ReadingFrame.TWO), strand, ReadingFrame.TWO); AbstractTierPanel tierPanel2 = new TierPanel(tier2, orientation, aar); /* Frame 3 */ aar = new AminoAcidRendererSpaced(2); TierI tier3 = new Tier( referenceFactory.getReference(strand, ReadingFrame.THREE), strand, ReadingFrame.THREE); AbstractTierPanel tierPanel3 = new TierPanel(tier3, orientation, aar); this.addPanel(tierPanel1); this.addPanel(tierPanel2); this.addPanel(tierPanel3); this.reformat(false); } public boolean canAddFeature(SeqFeatureI feature) { return false; } public void reformat(boolean isRecursive) { /* The DNA Reference for the current strand */ SequenceI reference = referenceFactory.getReference(getStrand(), ReadingFrame.NONE); AbstractTierPanel panel = getPanel(0); panel.getTier().setReference( referenceFactory.getReference(getStrand(), ReadingFrame.ONE)); panel.reformat(true); panel.setPreferredSize(new Dimension(reference.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); panel = getPanel(1); panel.getTier().setReference( referenceFactory.getReference(getStrand(), ReadingFrame.TWO)); panel.reformat(true); panel.setPreferredSize(new Dimension(reference.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); panel = getPanel(2); panel.getTier().setReference( referenceFactory.getReference(getStrand(), ReadingFrame.THREE)); panel.reformat(true); panel.setPreferredSize(new Dimension(reference.getLength() * panel.getBaseWidth(), panel.getBaseHeight())); super.reformat(isRecursive); } } --- NEW FILE: DNAMultiSequenceAlignerPanel.java --- package apollo.gui.detailviewers.sequencealigner.DNAPanel; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.List; import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JMenu; [...978 lines suppressed...] public MultiFilter getResultFilter() { return this.resultFilter; } @Override public void clearAnnotations() { this.annotations.clear(); this.annotationPanel.clear(); } @Override public AbstractScrollablePanel getAddressComponent() { return this.addressComponent; } } --- NEW FILE: HomogeneousPanel.java --- package apollo.gui.detailviewers.sequencealigner.DNAPanel; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.AbstractTierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder; import apollo.gui.detailviewers.sequencealigner.MultiTierPanel; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.PanelFactory; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.ReferenceFactoryI; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.Tier; import apollo.gui.detailviewers.sequencealigner.TierFactory; import apollo.gui.detailviewers.sequencealigner.TierFactoryI; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder.Type; import apollo.gui.detailviewers.sequencealigner.renderers.AnnotationRenderer; import apollo.gui.synteny.GuiCurationState; public class HomogeneousPanel extends MultiTierPanel { private PanelFactory panelFactory; public HomogeneousPanel(PanelFactory panelFactory) { super(FeaturePlaceFinder.Type.COMPACT); this.panelFactory = panelFactory; addPanel(panelFactory.makePanel()); } public HomogeneousPanel(PanelFactory panelFactory, FeaturePlaceFinder.Type finder) { super(finder); this.panelFactory = panelFactory; addPanel(panelFactory.makePanel()); } public boolean canAddFeature(SeqFeatureI feature) { return true; } public AbstractTierPanel addFeature(SeqFeatureI feature) { if (!super.canAddFeature(feature)) { addPanel(panelFactory.makePanel()); } return super.addFeature(feature); } public void switchStrand() { Strand strand = getStrand().getOpposite(); panelFactory.setStrand(strand); super.switchStrand(); } public void setStrand(Strand s) { panelFactory.setStrand(s); super.setStrand(s); } public void setReadingFrame(ReadingFrame rf) { panelFactory.setReadingFrame(rf); super.setReadingFrame(rf); } public void switchOrientation() { Orientation o = getOrientation().getOpposite(); panelFactory.setOrientation(o); super.setOrientation(o); } public void setOrientation(Orientation o){ panelFactory.setOrientation(o); super.setOrientation(o); } } --- NEW FILE: ReferencePanel.java --- package apollo.gui.detailviewers.sequencealigner.DNAPanel; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.AbstractTierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder; import apollo.gui.detailviewers.sequencealigner.MultiTierPanel; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.ReferenceFactoryI; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.Tier; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierPanel; import apollo.gui.detailviewers.sequencealigner.FeaturePlaceFinder.Type; import apollo.gui.detailviewers.sequencealigner.renderers.TestBaseRenderer; public class ReferencePanel extends MultiTierPanel { ReferenceFactoryI referenceFactory; MultiTierPanel annotationPanel; MultiTierPanel resultPanel; public ReferencePanel(ReferenceFactoryI referenceFactory, MultiTierPanel annotationPanel, MultiTierPanel resultPanel) { super(FeaturePlaceFinder.Type.COMPACT); this.referenceFactory = referenceFactory; this.annotationPanel = annotationPanel; this.resultPanel = resultPanel; // set the reference for the annotations SequenceI sequence = referenceFactory.getReference(annotationPanel.getStrand()); TierI tier = new Tier(sequence, annotationPanel.getStrand(), ReadingFrame.NONE); AbstractTierPanel panel = new TierPanel(tier, annotationPanel.getOrientation(), new TestBaseRenderer()); this.addPanel(panel); // set the reference for the results sequence = referenceFactory.getReference(resultPanel.getStrand()); tier = new Tier(sequence, resultPanel.getStrand(), ReadingFrame.NONE); panel = new TierPanel(tier, resultPanel.getOrientation(), new TestBaseRenderer()); this.addPanel(panel); /* if (annotationPanel.getStrand() == resultPanel.getStrand()) { panel.setOrientation(orientation); } else { panel.setOrientation(orientation.getOpposite()); } */ this.reformat(true); } public void reformat(boolean isRecursive) { getTier(0).setReference( referenceFactory.getReference(annotationPanel.getStrand())); getTier(0).setStrand(annotationPanel.getStrand()); getPanel(0).setOrientation(annotationPanel.getOrientation()); getTier(1).setReference( referenceFactory.getReference(resultPanel.getStrand())); getTier(1).setStrand(resultPanel.getStrand()); getPanel(1).setOrientation(resultPanel.getOrientation()); super.reformat(isRecursive); } } |
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/filters In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/filters Added Files: BaseFilter.java Filter.java FilterDisplayType.java FilterFactory.java FilterInverse.java FilterName.java FilterReadingFrame.java FilterSequenceType.java FilterStrand.java MultiFilter.java MultiFilterAnd.java MultiFilterOr.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: BaseFilter.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; public class BaseFilter<T> implements Filter<T>{ private boolean val; public BaseFilter() { val = true; } public BaseFilter(boolean v) { val = v; } public boolean keep(T f) { return val; } public String toString() { return valueToString(); } public String valueToString() { return "BaseFilter " + val; } } --- NEW FILE: Filter.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; public interface Filter<T> { public abstract boolean keep(T f); public abstract String valueToString(); } --- NEW FILE: FilterDisplayType.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.config.Config; import apollo.config.FeatureProperty; import apollo.datamodel.SeqFeatureI; public class FilterDisplayType implements Filter<SeqFeatureI> { private String displayType; public FilterDisplayType(String dt) { this.displayType = dt; } public boolean keep(SeqFeatureI f) { FeatureProperty fp = Config.getPropertyScheme() .getFeatureProperty(f.getTopLevelType()); return displayType.equalsIgnoreCase(fp.getDisplayType()); } public String toString() { return "Keep " + valueToString(); } public String valueToString() { return "DisplayType " + displayType; } } --- NEW FILE: FilterFactory.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.SequenceType; import apollo.gui.detailviewers.sequencealigner.Strand; public class FilterFactory { public static Filter<SeqFeatureI> makeFilter(Strand s) { return new FilterStrand(s); } public static Filter<SeqFeatureI> makeFilter(ReadingFrame rf){ return new FilterReadingFrame(rf); } public static Filter<SeqFeatureI> makeFilter(SequenceType st) { return new FilterSequenceType(st); } public static Filter<SeqFeatureI> makeFilterDisplayType(String s) { return new FilterDisplayType(s); } public static Filter<SeqFeatureI> makeFilterName(String n) { return new FilterName(n); } public static Filter makeInverse(Filter f) { return new FilterInverse(f); } public static MultiFilter makeMultiFilterAnd() { return new MultiFilterAnd(); } public static MultiFilter makeMultiFilterOr() { return new MultiFilterOr(); } } --- NEW FILE: FilterInverse.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; public class FilterInverse<T> implements Filter<T> { private Filter<T> filter; public FilterInverse(Filter<T> f) { filter = f; } public boolean keep(T f) { return !filter.keep(f); } public String toString() { return "Remove " + filter.valueToString(); } public String valueToString() { return filter.valueToString(); } } --- NEW FILE: FilterName.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; public class FilterName implements Filter<SeqFeatureI> { private String name; public FilterName(String name) { this.name = name; } public boolean keep(SeqFeatureI f) { return f.getName().equals(name); } public String toString() { return "Keep " + valueToString(); } public String valueToString() { return "Name " + name; } } --- NEW FILE: FilterReadingFrame.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; public class FilterReadingFrame implements Filter<SeqFeatureI> { private ReadingFrame readingFrame; public FilterReadingFrame(ReadingFrame rf) { readingFrame = rf; } public boolean keep(SeqFeatureI f) { return f.getFrame() == readingFrame.toInt(); } public String toString() { return "Keep " + valueToString(); } public String valueToString() { return "ReadingFrame " + readingFrame; } } --- NEW FILE: FilterSequenceType.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.SequenceType; public class FilterSequenceType implements Filter<SeqFeatureI> { private SequenceType sequenceType; public FilterSequenceType(SequenceType st) { sequenceType = st; } public boolean keep(SeqFeatureI f) { SequenceI sequence = f.getFeatureSequence(); String seqType = sequence.getResidueType(); String alignment = f.getExplicitAlignment(); return alignment != null && (sequenceType.toString().equals(seqType) || sequenceType.equals(SequenceType.AA) == isAminoAcid(alignment)); } public String toString() { return "Keep " + valueToString(); } //TODO:find a way to figure out if the alignment or feature is an aminoAcid... private boolean isAminoAcid(String a) { return a.contains("E") || a.contains("V") || a.contains("P") || a.contains("M") || a.contains("R") || a.contains("Q") || a.contains("L") || a.contains("Y") || a.contains("S") || a.contains("H"); } public String valueToString() { return "Sequence Type " + sequenceType; } } --- NEW FILE: FilterStrand.java --- package apollo.gui.detailviewers.sequencealigner.filters; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.Strand; public class FilterStrand implements Filter<SeqFeatureI>{ private Strand strand; public FilterStrand(Strand s) { strand = s; } public boolean keep(SeqFeatureI f) { return f.getStrand() == strand.toInt(); } public String toString() { return "Keep " + valueToString(); } public String valueToString() { return "Strand " + strand; } } --- NEW FILE: MultiFilter.java --- package apollo.gui.detailviewers.sequencealigner.filters; import java.util.List; public interface MultiFilter<T> extends Filter<T>, List<Filter<T>> { } --- NEW FILE: MultiFilterAnd.java --- package apollo.gui.detailviewers.sequencealigner.filters; import java.util.ArrayList; import java.util.List; import apollo.datamodel.SeqFeatureI; public class MultiFilterAnd<T> extends ArrayList<Filter<T>> implements MultiFilter<T> { public MultiFilterAnd() { super(); this.add(new BaseFilter<T>(true)); } public boolean keep(T f) { boolean result = true; for (Filter<T> filter : this) { result = result && filter.keep(f); } return result; } public String toString() { return "Keep " + valueToString(); } public String valueToString() { String s = "["; boolean isFirst = true; for (Filter f : this) { if (!isFirst) { s += " AND "; } s += "(" + f + ")"; isFirst = false; } s += "]"; return s; } } --- NEW FILE: MultiFilterOr.java --- package apollo.gui.detailviewers.sequencealigner.filters; import java.util.ArrayList; import java.util.List; import apollo.datamodel.SeqFeatureI; public class MultiFilterOr<T> extends ArrayList<Filter<T>> implements MultiFilter<T> { public MultiFilterOr() { super(); this.add(new BaseFilter<T>(false)); } public boolean keep(T f) { boolean result = false; for (Filter<T> filter : this) { result = result || filter.keep(f); } return result; } public String toString() { return "Keep " + valueToString(); } public String valueToString() { String s = "["; boolean isFirst = true; for (Filter f : this) { if (!isFirst) { s += " OR "; } s += "(" + f + ")"; isFirst = false; } s += "]"; return s; } } |
From: elee <gk...@us...> - 2009-06-02 16:50:25
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/renderers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/renderers Added Files: AminoAcidBaseRenderer.java AminoAcidRenderer.java AminoAcidRendererSpaced.java AnnotationRenderer.java BaseRenderer.java BaseRendererI.java DNAResultRenderer.java ResultRendererFactory.java TestBaseRenderer.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AminoAcidBaseRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.util.HashMap; import java.util.Map; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.TierI; public class AminoAcidBaseRenderer extends TestBaseRenderer { private static final Map<String, Color> colors = new HashMap<String, Color>(); private static final Color disabled = new Color(200, 200, 200); private static final Font regularFont = apollo.config.Config .getExonDetailEditorSequenceFont(); private static final Font boldFont = new Font("Dialog", Font.BOLD, regularFont.getSize()); static { colors.put("M", Color.green); colors.put("*", Color.red); } private int offset; private Orientation orientation; public AminoAcidBaseRenderer(int offset, Orientation orientation) { super(); this.offset = offset; this.orientation = orientation; } // this is a base pair position even though we mean to // use this to render only 1/3 of the bases public Component getBaseComponent(int position, TierI tier, Orientation o) { char base = '\0'; if (orientation == Orientation.FIVE_TO_THREE) { position = position*3 + offset; } else { int min = tier.getHigh() - (tier.getHigh()/3); int index = position - min; position = index*3 + offset; } int bp = tier.getBasePair(position); String r = tier.getReference().getResidues(); if (position < tier.getReference().getLength()) { base = tier.charAt(position); } if (colors.get(base + "") == null) setFont(regularFont); else setFont(boldFont); super.init(base); return this; } public Color getTextColor() { Color stored = colors.get(getBase() + ""); if (stored == null) return disabled; else return stored; } public int pixelPositionToTierPosition(int p, TierI t, Orientation o) { if (o == Orientation.THREE_TO_FIVE) { p = t.getHigh()/3 - p; } return p; } public int tierPositionToPixelPosition(int p, TierI t, Orientation o) { if (o == Orientation.THREE_TO_FIVE) { p = t.getHigh()/3 - p; } return p; } } --- NEW FILE: AminoAcidRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.util.HashMap; import java.util.Map; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.TierI; public class AminoAcidRenderer extends TestBaseRenderer { private static final Map<String, Color> colors = new HashMap<String, Color>(); private static final Color disabled = new Color(200, 200, 200); private static final Font regularFont = apollo.config.Config .getExonDetailEditorSequenceFont(); private static final Font boldFont = new Font("Dialog", Font.BOLD, regularFont.getSize()); static { colors.put("M", Color.green); colors.put("*", Color.red); } private ReadingFrame frame; public AminoAcidRenderer(ReadingFrame frame) { super(); this.frame = frame; } public Component getBaseComponent(int position, TierI tier, Orientation o) { char base = '\0'; int bp = tier.getBasePair(position); if (position < tier.getReference().getLength()) { base = tier.charAt(position); } if (colors.get(base + "") == null) setFont(regularFont); else setFont(boldFont); super.init(base); return this; } public Color getTextColor() { Color stored = colors.get(getBase() + ""); if (stored == null) return disabled; else return stored; } } --- NEW FILE: AminoAcidRendererSpaced.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.util.Map; import java.util.HashMap; import apollo.datamodel.RangeI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.TierI; public class AminoAcidRendererSpaced extends TestBaseRenderer { private static final Map<String, Color> colors = new HashMap<String, Color>(); private static final Color disabled = new Color(200, 200, 200); private static final Font regularFont = apollo.config.Config .getExonDetailEditorSequenceFont(); private static final Font boldFont = new Font("Dialog", Font.BOLD, regularFont.getSize()); static { colors.put("M", Color.green); colors.put("*", Color.red); } private int phase; public AminoAcidRendererSpaced(int phase) { super(); this.phase = phase; } public Component getBaseComponent(int position, TierI tier, Orientation o) { char base = '\0'; if (position >= 0 && position < tier.getReference().getLength()) { base = tier.charAt(position); } // TODO: hit zones.... if (colors.get(base + "") == null) setFont(regularFont); else setFont(boldFont); super.init(base); return this; } public Color getTextColor() { Color stored = colors.get(getBase() + ""); if (stored == null) return disabled; else return stored; } public int pixelPositionToTierPosition(int p, TierI t, Orientation o) { int position = p/3; if (o == Orientation.THREE_TO_FIVE) { // the reference length is different depending on what strand the SequenceI s = t.getReference(); int l = t.getReference().getLength(); // Given a set genomic region, the length of the generated amino acid // sequence may not be the same for every phase RangeI r = t.getReference().getRange(); int rle = r.getHigh() - r.getLow() + 1; int extra_bases = (rle-(int)Math.abs(phase)) % 3; position = t.getHigh() - position; // will this work in every case? See translate() if (extra_bases == 0) { position -= 1; } if (extra_bases == 2) { position -= 1; } //position -= extra_bases; //position -= phase; p -= phase; } if (p % 3 != phase) { position = -1; } return position; } public int tierPositionToPixelPosition(int p, TierI t, Orientation o) { // is this right? does it matter? int position = p; if (o == Orientation.THREE_TO_FIVE) { position = t.getHigh()*3 - position; } return position; } } --- NEW FILE: AnnotationRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.util.HashMap; import java.util.Map; import java.util.Vector; import apollo.datamodel.ExonI; import apollo.datamodel.FeatureSet; import apollo.datamodel.FeatureSetI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.datamodel.Transcript; import apollo.datamodel.TranslationI; import apollo.gui.detailviewers.sequencealigner.AnnotationEditorMouseListener; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.RegionSelectableI; import apollo.gui.detailviewers.sequencealigner.SequenceType; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierI.Level; import apollo.gui.drawable.DrawableSeqFeature; import apollo.gui.drawable.DrawableUtil; import apollo.gui.synteny.GuiCurationState; import org.bdgp.util.Range; import sun.text.CompactShortArray.Iterator; public class AnnotationRenderer extends TestBaseRenderer implements RegionSelectableI { private static enum State { MISS, INTRON, EXON, OUT, X, SELECTED, SHIFT, ERROR, TRANSLATION_START, TRANSLATION_END, UTR, }; private static final Map<State, Color> bgColorMap = new HashMap<State, Color>(); private static final Map<State, Color> lineColorMap = new HashMap<State, Color>(); static { bgColorMap.put(State.MISS, Color.LIGHT_GRAY); // shouldn't ever happen for annotations bgColorMap.put(State.INTRON, Color.black); bgColorMap.put(State.UTR, Color.black); bgColorMap.put(State.EXON, Color.blue); bgColorMap.put(State.OUT, Color.black); bgColorMap.put(State.X, Color.pink); bgColorMap.put(State.SELECTED, Color.cyan); bgColorMap.put(State.SHIFT, Color.ORANGE); bgColorMap.put(State.ERROR, Color.pink); bgColorMap.put(State.TRANSLATION_START, Color.green); //bgColorMap.put(State.NON_STANDARD_START, new Color(160, 32, 240)); // purple bgColorMap.put(State.TRANSLATION_END, Color.red); bgColorMap.put(State.UTR, new Color(70, 130, 180)); }; static { lineColorMap.put(State.INTRON, Color.blue); lineColorMap.put(State.UTR, new Color(70, 130, 180)); } private State state; private int selectionStart, selectionEnd; private GuiCurationState curationState; private Transcript currentParent; private Transcript currentParentClone; // for full translation private Transcript currentParentClone2; // to get the correct feature private int currentStart; private int featureStart; private int featureEnd; // needed to get the translation start color private Transcript transcript; public AnnotationRenderer(GuiCurationState curationState) { super(); this.curationState = curationState; this.state = State.OUT; selectionStart = -1; selectionEnd = -1; transcript = null; currentParent = null; currentParentClone = null; currentParentClone2 = null; currentStart = -1; featureStart = -1; featureEnd = -1; } /** * Get component to be rendered, if pos outside of current range * getFeatureAtPosition and reset currentRange, if feature is non null and not * an instance of FeatureSetI then its an exon, and set isExon flag */ public Component getBaseComponent(int position, TierI tier, Orientation o) { transcript = null; int bp = tier.getBasePair(position); int oldPos = position; // We need to change the position if dealing with aa view if (tier.getType() == SequenceType.AA) { int offset = getOffset(position, tier); bp += offset*tier.getStrand().toInt(); position = tier.getPosition(bp); } char base = tier.charAt(position); if (tier.featureExsitsAt(position, TierI.Level.BOTTOM)) { this.state = State.EXON; SeqFeatureI feature = tier.featureAt(position, TierI.Level.BOTTOM); Transcript parentClone = null; Transcript otherParentClone = null; if (tier.getType() == SequenceType.AA && feature.getParent() != null && feature.getParent().isTranscript() ) { FeatureSetI parent = feature.getParent(); int index = parent.getFeatureIndex(feature); int start = parent.getEnd(); // the transcript start might be different than the lowest exon start // when in the middle of an edit if (parent.canHaveChildren()) { for (int i=0; i< parent.size(); i++) { SeqFeatureI sf = parent.getFeatureAt(i); if ((Strand.valueOf(sf.getStrand()) == Strand.FORWARD && sf.getStart() < start) || (Strand.valueOf(sf.getStrand()) == Strand.REVERSE && sf.getStart() > start)) start = sf.getStart(); } } int translationStart = parent.getTranslationStart(); int translationEnd = parent.getTranslationEnd(); int translationPos = parent.getFeaturePosition(translationStart); int oldstart = start; start += ((translationPos-1)%3)*parent.getStrand(); // Tring to avoid all the recalculation... if (feature.getParent() == currentParent && start == currentStart && featureStart == feature.getStart() && featureEnd == feature.getEnd()) { parentClone = currentParentClone; otherParentClone = currentParentClone2; } else { // need to get a full translation so that we can get the amino acids // in the UTR region parentClone = (Transcript)feature.getParent().clone(); otherParentClone = (Transcript)feature.getParent().clone(); if (!parentClone.setTranslationStart(start)) { start = oldstart; TranslationI cds = otherParentClone.getTranslation(); cds.calcTranslationStartForLongestPeptide(); translationStart = otherParentClone.getTranslationStart(); translationPos = otherParentClone.getFeaturePosition(translationStart); start += ((translationPos-1)%3)*otherParentClone.getStrand(); parentClone.setTranslationStart(start); } parentClone.setTranslationEnd(parentClone.getEnd()); parentClone.setPeptideSequence(null); String translation = parentClone.translate(); SequenceI sequence = parentClone.getPeptideSequence(); currentParent = (Transcript) feature.getParent(); currentParentClone = parentClone; currentParentClone2 = otherParentClone; currentStart = start; featureStart = feature.getStart(); featureEnd = feature.getEnd(); if (otherParentClone.getFeatureContaining(translationEnd) == null){ TranslationI cds = otherParentClone.getTranslation(); cds.setTranslationEndFromStart(); } } SeqFeatureI sf = parentClone.getFeatureAt(index); if (bp >= sf.getLow() && bp <= sf.getHigh()) { base = getPeptide(bp, sf); } else { base = '\0'; } if (otherParentClone != null) { feature = otherParentClone.getFeatureAt(index); } } else if (tier.getType() == SequenceType.AA && feature.getParent() != null && !feature.getParent().isTranscript()) { base = '\0'; } if (isUTR(bp, feature, tier)) { this.state = State.UTR; } if (isTranslationStart(bp, feature)) { this.state = State.TRANSLATION_START; } if (isTranslationEnd(bp, feature)) { this.state = State.TRANSLATION_END; } // Can have an error or a shift on a position but not both if (isSequencingErrorPosition(bp, feature, tier.getType())) { this.state = State.ERROR; // set base to the base of the new sequence? } if (isShiftPosition(bp, feature, tier.getType())) { this.state = State.SHIFT; } } else if (tier.featureExsitsAt(position, TierI.Level.TOP)) { SeqFeatureI feature = tier.featureAt(position, Level.TOP); this.state = State.INTRON; if (tier.getType() == SequenceType.AA) { base = '\0'; } int start = feature.getEnd(); int end = feature.getStart(); if (feature.canHaveChildren()) { for (int i=0; i<feature.size(); i++) { SeqFeatureI sf = feature.getFeatureAt(i); if ((Strand.valueOf(sf.getStrand()) == Strand.FORWARD && sf.getStart() < start) || (Strand.valueOf(sf.getStrand()) == Strand.REVERSE && sf.getStart() > start)) start = sf.getStart(); if ((Strand.valueOf(sf.getStrand()) == Strand.FORWARD && sf.getEnd() > end) || (Strand.valueOf(sf.getStrand()) == Strand.REVERSE && sf.getEnd() < end)) end = sf.getEnd(); } } if (bp <= Math.min(start, end) || bp >= Math.max(start, end)) { this.state = State.OUT; base = '\0'; } } else { this.state = State.OUT; base = '\0'; } if (!(state == State.SHIFT || state == State.ERROR) && getRegionLow() <= position && position <= getRegionHigh()) { this.state = State.SELECTED; base = tier.charAt(oldPos); } init(base); return this; } public Color getBackgroundBoxColor() { Color c = bgColorMap.get(state); if (state == State.TRANSLATION_START && transcript != null) { c = DrawableUtil.getStartCodonColor(transcript); } return c; } public Color getBackgroundLineColor() { return lineColorMap.get(state); } public Color getTextColor() { return Color.white; } public int getRegionEnd() { return selectionEnd; } public int getRegionStart() { return selectionStart; } public void setRegionEnd(int pos) { selectionEnd = pos; } public void setRegionStart(int pos) { selectionStart = pos; } public int getRegionHigh() { return Math.max(selectionStart, selectionEnd); } public int getRegionLow() { return Math.min(selectionStart, selectionEnd); } private boolean isSequencingErrorPosition(int bp, SeqFeatureI feature, SequenceType type) { boolean result = false; if (type == SequenceType.DNA) { result = curationState.getCurationSet().getRefSequence().isSequencingErrorPosition(bp); } else { result = curationState.getCurationSet().getRefSequence().isSequencingErrorPosition(bp) || curationState.getCurationSet().getRefSequence().isSequencingErrorPosition(bp + feature.getStrand()) || curationState.getCurationSet().getRefSequence().isSequencingErrorPosition(bp + (2*feature.getStrand())); } return result; } private boolean isShiftPosition(int bp, SeqFeatureI feature, SequenceType type) { boolean result = false; // Can shifts only happen on exons? if (feature != null) { FeatureSet fs = (FeatureSet) feature.getRefFeature(); result = fs.plus1FrameShiftPosition() == bp || fs.minus1FrameShiftPosition() == bp; if (type == SequenceType.AA) { bp += feature.getStrand(); result = result || fs.plus1FrameShiftPosition() == bp || fs.minus1FrameShiftPosition() == bp; } if (type == SequenceType.AA) { bp += feature.getStrand(); result = result || fs.plus1FrameShiftPosition() == bp || fs.minus1FrameShiftPosition() == bp; } } return result; } private boolean isTranslationStart(int bp, SeqFeatureI feature) { boolean result = false; ExonI exon = null; if (feature instanceof ExonI) exon = (ExonI) feature; else if (feature instanceof DrawableSeqFeature) exon = (ExonI) ((DrawableSeqFeature) feature).getFeature(); if (exon != null && exon.getTranscript() != null) { transcript = exon.getTranscript(); // do this to get the start color int tss = (int) exon.getTranscript().getTranslationStart(); result = bp == tss || bp == (tss + exon.getStrand()) || bp == (tss + (2 * exon.getStrand())); } return result; } private boolean isTranslationEnd(int bp, SeqFeatureI feature) { boolean result = false; ExonI exon = null; if (feature instanceof ExonI) exon = (ExonI) feature; else if (feature instanceof DrawableSeqFeature) exon = (ExonI) ((DrawableSeqFeature) feature).getFeature(); if (exon != null && exon.getTranscript() != null) { int tes = (int) exon.getTranscript().getTranslationEnd(); result = bp == tes || bp == (tes + exon.getStrand()) || bp == (tes + (2 * exon.getStrand())); } return result; } private boolean isUTR(int bp, SeqFeatureI feature, TierI tier) { boolean isStartUTR = false; boolean isEndUTR = false; ExonI exon = null; if (feature instanceof ExonI) exon = (ExonI) feature; else if (feature instanceof DrawableSeqFeature) exon = (ExonI) ((DrawableSeqFeature) feature).getFeature(); // EndUTR goes from the end of the translationEnd to the end of the transcript if (exon != null && exon.getTranscript() != null) { int utrStart = exon.getTranscript().getTranslationEnd() + (2 * exon.getStrand()); int utrEnd = exon.getTranscript().getEnd(); utrStart = tier.getPosition(utrStart); utrEnd = tier.getPosition(utrEnd); int pos = tier.getPosition(bp); isEndUTR = utrStart <= pos && exon.getTranscript().hasTranslationEnd();; } // StartUTR if (exon != null && exon.getTranscript() != null) { int utrStart = exon.getTranscript().getStart(); int utrEnd = exon.getTranscript().getTranslationStart(); utrStart = tier.getPosition(utrStart); utrEnd = tier.getPosition(utrEnd); int pos = tier.getPosition(bp); isStartUTR = pos <= utrEnd && exon.getTranscript().hasTranslationStart(); } return isStartUTR || isEndUTR; } /* only call on an exon position */ private char getPeptide(int bp, SeqFeatureI sf) { char base = '\0'; SequenceI peptides = null; FeatureSetI parent = sf.getParent(); int pepPos = -1; if (parent != null && parent.hasPeptideSequence()) { peptides = parent.getPeptideSequence(); if (parent instanceof FeatureSet) { FeatureSet fs = (FeatureSet) parent; pepPos = fs.getPeptidePosForGenomicPos(bp); } if (pepPos >= 0 && pepPos < peptides.getLength()) { base = peptides.getBaseAt(pepPos); } } return base; } /** * * @param position * @param tier * @return */ public static int getOffset(int position, TierI tier) { SeqFeatureI sf = null; int offset = 0; if (tier.featureExsitsAt(position, Level.BOTTOM)) { sf = tier.featureAt(position, Level.BOTTOM); ReadingFrame exonFrame = ReadingFrame.valueOf(sf.getFrame()); ReadingFrame tierFrame = tier.getReadingFrame(); if (exonFrame == ReadingFrame.NONE && sf.getParent() != null && sf.getParent().isTranscript()) { FeatureSetI parent = sf.getParent(); Transcript parentClone = (Transcript)sf.getParent().clone(); int start = parentClone.getEnd(); // the transcript start might be different than the lowest exon start // when in the middle of an edit if (parentClone.canHaveChildren()) { for (int i=0; i< parentClone.size(); i++) { SeqFeatureI f = parentClone.getFeatureAt(i); if ((Strand.valueOf(f.getStrand()) == Strand.FORWARD && f.getStart() < start) || (Strand.valueOf(f.getStrand()) == Strand.REVERSE && f.getStart() > start)) start = f.getStart(); } } int translationStart = parentClone.getTranslationStart(); int translationPos = parentClone.getFeaturePosition(translationStart); int oldstart = start; start += ((translationPos-1)%3)*parentClone.getStrand(); parentClone.setTranslationStart(start); parentClone.setTranslationEnd(parentClone.getEnd()); parentClone.setPeptideSequence(null); String translation = parentClone.translate(); SequenceI sequence = parentClone.getPeptideSequence(); int index = parent.getFeatureIndex(sf); exonFrame = ReadingFrame.valueOf(parentClone.getFeatureAt(index).getFrame()); } if (tierFrame != exonFrame && sf.getParent() != null && sf.getParent().isTranscript()) { if (tierFrame == ReadingFrame.THREE) { offset = exonFrame == ReadingFrame.ONE ? -2 : -1; } else if (tierFrame == ReadingFrame.TWO) { offset = exonFrame == ReadingFrame.ONE ? -1 : 1; } else if (tierFrame == ReadingFrame.ONE) { offset = exonFrame == ReadingFrame.TWO ? 1 : 2; } } if (exonFrame == ReadingFrame.NONE) { offset = 0; } } return offset; } } --- NEW FILE: BaseRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.*; import apollo.datamodel.*; public interface BaseRenderer { /* public void paintNotify(); public Component getBaseRendererComponent(char base, int pos, int tier, SequenceI seq); public boolean canRender(SeqFeatureI feature); //public void setTier(int tier); * * */ } --- NEW FILE: BaseRendererI.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Component; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.TierI; public interface BaseRendererI { public Component getBaseComponent(int pos, TierI tier, Orientation o); public int pixelPositionToTierPosition(int p, TierI t, Orientation o); public int tierPositionToPixelPosition(int p, TierI t, Orientation o); public int getBaseWidth(); public int getBaseHeight(); } --- NEW FILE: DNAResultRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.util.Map; import java.util.TreeMap; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bdgp.util.DNAUtils; import apollo.config.Config; import apollo.config.FeatureProperty; import apollo.datamodel.FeaturePair; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.SequenceType; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.TierI; import apollo.gui.detailviewers.sequencealigner.TierI.Level; public class DNAResultRenderer extends TestBaseRenderer { private static final int STATE_MISS = 1; private static final int STATE_MATCH = 2; private static final int STATE_OUT = 3; private static final int STATE_X = 4; private static final int STATE_NO_ALIGNMENT = 5; private static final Map<Integer, Color> stateColorMap = new HashMap<Integer, Color>(); private static final Map<String, Color> baseColorMap = new HashMap<String, Color>(); static { stateColorMap.put(STATE_MISS, Color.black); stateColorMap.put(STATE_MATCH, Color.magenta); stateColorMap.put(STATE_OUT, Color.black); stateColorMap.put(STATE_X, Color.white); stateColorMap.put(STATE_NO_ALIGNMENT, Color.blue); }; // Colors based on: http://www.jalview.org/help.html zappos static { baseColorMap.put("I", new Color(250, 128, 114)); baseColorMap.put("L", new Color(250, 128, 114)); baseColorMap.put("V", new Color(250, 128, 114)); baseColorMap.put("A", new Color(250, 128, 114)); baseColorMap.put("M", new Color(250, 128, 114)); baseColorMap.put("F", new Color(255, 165, 0)); baseColorMap.put("W", new Color(255, 165, 0)); baseColorMap.put("Y", new Color(255, 165, 0)); baseColorMap.put("K", new Color(131, 111, 255)); baseColorMap.put("R", new Color(131, 111, 255)); baseColorMap.put("H", new Color(131, 111, 255)); baseColorMap.put("D", new Color(192, 0, 0)); baseColorMap.put("E", new Color(192, 0, 0)); baseColorMap.put("S", new Color(9, 249, 17)); baseColorMap.put("T", new Color(9, 249, 17)); baseColorMap.put("N", new Color(9, 249, 17)); baseColorMap.put("Q", new Color(9, 249, 17)); baseColorMap.put("P", new Color(205, 0, 205)); baseColorMap.put("G", new Color(205, 0, 205)); baseColorMap.put("C", new Color(255, 255, 0)); baseColorMap.put("-", new Color(205, 133, 0)); } private static Color insertionColor = new Color(255, 255, 0); private Integer state; private int outlineType; private SeqFeatureI feature; private boolean easyRead; public DNAResultRenderer() { super(); this.state = STATE_OUT; this.outlineType = NO_OUTLINE; this.easyRead = false; } public DNAResultRenderer(boolean easyRead) { super(); this.state = STATE_OUT; this.outlineType = NO_OUTLINE; this.easyRead = easyRead; } public Color getBackgroundBoxColor() { Color bgColor = stateColorMap.get(state); if (state.equals(STATE_MATCH) && !easyRead) { FeatureProperty fp = Config.getPropertyScheme().getFeatureProperty(feature.getTopLevelType()); bgColor = fp.getColour(); } return bgColor; } public int getOutlineType() { return outlineType; } public Color getOutlineColor() { return insertionColor; } public Color getTextColor() { Color txColor = Color.white; if (state.equals(STATE_MISS)) { txColor = baseColorMap.get(String.valueOf(getCharacter())); if (txColor == null) { txColor = Color.pink; } } return txColor; } /* position is the tier position */ public Component getBaseComponent(int position, TierI tier, Orientation o) { this.outlineType = NO_OUTLINE; char base = tier.charAt(position); int bp = tier.getBasePair(position); feature = null; if (tier.featureExsitsAt(position, TierI.Level.BOTTOM)) { feature = tier.featureAt(position, TierI.Level.BOTTOM); this.state = STATE_MATCH; } else { this.state = STATE_OUT; } if (this.state == STATE_MATCH && feature instanceof FeaturePair) { FeaturePair fp = (FeaturePair) feature; int basePair = tier.getBasePair(position); if (tier.getType() == SequenceType.AA) { ReadingFrame exonFrame = ReadingFrame.valueOf(feature.getFrame()); ReadingFrame tierFrame = tier.getReadingFrame(); int offset = 0; if (tierFrame != exonFrame) { if (tierFrame == ReadingFrame.THREE) { offset = exonFrame == ReadingFrame.ONE ? -2 : -1; } else if (tierFrame == ReadingFrame.TWO) { offset = exonFrame == ReadingFrame.ONE ? -1 : 1; } else if (tierFrame == ReadingFrame.ONE) { offset = exonFrame == ReadingFrame.TWO ? 1 : 2; } } basePair += (offset*feature.getStrand()); } int hitIndex = fp.getHitIndex(basePair, tier.getReference().getResidueType()); int hi = fp.getHitIndex(bp, tier.getReference().getResidueType()); // Check for insertions if (hitIndex >= 0 && fp.getQueryFeature().getExplicitAlignment() != null) { hitIndex += fp.insertionsBefore(hitIndex, fp.getQueryFeature().getExplicitAlignment()); // do i need to modify this based on the tier orientation? if (hitIndex-1 > 0 && hitIndex-1 < fp.getQueryFeature().getExplicitAlignment().length() && '-' == fp.getQueryFeature().getExplicitAlignment().charAt(hitIndex-1)) { if (o == Orientation.FIVE_TO_THREE) { this.outlineType = this.LEFT_OUTLINE; } else { this.outlineType = this.RIGHT_OUTLINE; } } if (hitIndex+1 < fp.getQueryFeature().getExplicitAlignment().length() && '-' == fp.getQueryFeature().getExplicitAlignment().charAt(hitIndex+1)) { if (o == Orientation.FIVE_TO_THREE) { this.outlineType = this.RIGHT_OUTLINE; } else { this.outlineType = this.LEFT_OUTLINE; } } } if (fp.getHitFeature().getExplicitAlignment() != null) { // get the basepair position for the position in the tier char hitBase = base; if (hitIndex > -1 && hitIndex < fp.getHitFeature().getExplicitAlignment().length()) { hitBase = fp.getHitFeature().getExplicitAlignment().charAt(hitIndex); } else { this.state = STATE_OUT; } if (hitBase != base) { this.state = STATE_MISS; base = hitBase; } } else { this.state = STATE_NO_ALIGNMENT; } } else { // what else could this be? if (state.equals(STATE_MATCH)) { this.state = STATE_OUT; } } if (this.state.equals(this.STATE_OUT)) { base = '\0'; } init(base); return this; } } --- NEW FILE: ResultRendererFactory.java --- package apollo.gui.detailviewers.sequencealigner.renderers; public class ResultRendererFactory { private boolean easyRead; public ResultRendererFactory(boolean easyRead) { this.easyRead = easyRead; } public BaseRendererI makeRenderer() { return new DNAResultRenderer(easyRead); } public boolean getEasyRead() { return easyRead; } public void setEasyRead(boolean easyRead) { this.easyRead = easyRead; } } --- NEW FILE: TestBaseRenderer.java --- package apollo.gui.detailviewers.sequencealigner.renderers; import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import javax.swing.JComponent; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.gui.detailviewers.sequencealigner.Orientation; import apollo.gui.detailviewers.sequencealigner.TierI; public class TestBaseRenderer extends JComponent implements BaseRendererI { public static final int NO_OUTLINE = 0; public static final int LEFT_OUTLINE = 1; public static final int CENTER_OUTLINE = 2; public static final int RIGHT_OUTLINE = 3; private char character; public TestBaseRenderer() { setFont(apollo.config.Config.getExonDetailEditorSequenceFont()); setBorder(null); setForeground(Color.white); setBackground(Color.black); setSize(getFont().getSize(), getFont().getSize()); setPreferredSize(getSize()); setOpaque(true); } public Color getBrokenEdgeColor() { return null; } public void paintNotify() { } public Component getBaseComponent(int pos, TierI tier, Orientation o) { init(tier.charAt(pos)); return this; } protected void init(char base) { this.setCharacter(base); } public char getBase() { return this.getCharacter(); } public Color getTextColor() { return getForeground(); } public int getBaseHeight() { return getSize().height; } public int getBaseWidth() { return getSize().width; } public Color getBackgroundBoxColor() { return getBackground(); } public Color getBackgroundLineColor() { return null; } public Color getHatchColor() { return null; } public int getOutlineType() { return NO_OUTLINE; } public Color getOutlineColor() { return null; } public void paint(Graphics g) { g.setFont(getFont()); Color boxColor = getBackgroundBoxColor(); Color hatchColor = getHatchColor(); Color backgroundLineColor = getBackgroundLineColor(); Color textColor = getTextColor(); int outlineType = getOutlineType(); Color outlineColor = getOutlineColor(); Color brokenEdgeColor = getBrokenEdgeColor(); if (boxColor != null) { g.setColor(boxColor); g.fillRect(0, 0, getSize().width, getSize().height); } if (backgroundLineColor != null) { g.setColor(backgroundLineColor); g.fillRect(0, getSize().height / 2 - 1, getSize().width, 2); } if (hatchColor != null) { g.setColor(hatchColor); // Draw box around residue (instead of crosshatches) g.drawLine(0, getSize().height, getSize().width, getSize().height); // bottom g.drawLine(0, 0, getSize().width, 0); // top g.drawLine(0, 0, 0, getSize().height); // left side // need to subtract one from width, else get drawn over by next base g.drawLine(getSize().width - 1, 0, getSize().width - 1, getSize().height); // right // side } if (brokenEdgeColor != null) { final int squiggleCount = 4; int triangleHeight = 1 + (getSize().height / squiggleCount); int triangleWidth = 1 + (getSize().width / 5); for (int i = 0; i < squiggleCount - 1; i++) { g.setColor(brokenEdgeColor); g.drawLine(0, i * triangleHeight, triangleWidth, i * triangleHeight + triangleHeight / 2); g.drawLine(triangleWidth, i * triangleHeight + triangleHeight / 2, 0, (i + 1) * triangleHeight); } } // Draw a line on the right or left boarder if (outlineType != NO_OUTLINE && outlineColor != null) { g.setColor(outlineColor); if (outlineType == LEFT_OUTLINE) { g.drawLine(0, 0, 0, getSize().height); } else if (outlineType == RIGHT_OUTLINE) { g.drawLine(getSize().width - 1, 0, getSize().width - 1, getSize().height); } } // Print the base if (textColor != null) { FontMetrics metrics = this.getFontMetrics(this.getFont()); int widthLead = (getSize().width - metrics.charWidth(getCharacter())) / 2; int heightLead = (getSize().height / 100) + 1; // XXX: set height lead correctly g.setColor(textColor); g.drawString(getCharacter() + "", widthLead, getSize().height - heightLead); } } public void setCharacter(char character) { this.character = character; } public char getCharacter() { return character; } public boolean isSelectable() { return false; } public boolean setTargetPosition(int pos) { return isSelectable(); } public int pixelPositionToTierPosition(int p, TierI t, Orientation o) { if (o == Orientation.THREE_TO_FIVE) { p = t.getHigh() - p; } return p; } public int tierPositionToPixelPosition(int p, TierI t, Orientation o) { if (o == Orientation.THREE_TO_FIVE) { p = t.getHigh() - p; } return p; } } |
From: elee <gk...@us...> - 2009-06-02 16:50:25
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/listeners In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/listeners Added Files: AnnotationHeaderMouseListener.java ResultHeaderMouseListener.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AnnotationHeaderMouseListener.java --- package apollo.gui.detailviewers.sequencealigner.listeners; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import apollo.datamodel.AnnotatedFeatureI; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.MultiTierPanelHeaderTable; import apollo.gui.detailviewers.sequencealigner.TierPanelI; import apollo.gui.detailviewers.sequencealigner.TierI.Level; public class AnnotationHeaderMouseListener implements MouseListener { private MultiSequenceAlignerPanel panel; public AnnotationHeaderMouseListener(MultiSequenceAlignerPanel panel) { this.panel = panel; } /** * Sets the annotation whos name is displayed in the box as the selected * annotation */ public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); Object source = e.getSource(); if (source instanceof MultiTierPanelHeaderTable) { MultiTierPanelHeaderTable table = (MultiTierPanelHeaderTable) source; int tier = table.calculateTierNumber(point); TierPanelI tierPanel = panel.getAnnotationPanel().getPanel(tier); int bp = panel.getVisibleBase(); int position = tierPanel.tierPositionToPixelPosition( tierPanel.getTier().getPosition(bp)); SeqFeatureI feature = tierPanel.featureAt(position, Level.TOP); if (feature == null) { feature = tierPanel.getNextFeature(position, Level.TOP); } if (feature != null && feature instanceof AnnotatedFeatureI && table.isVisible(feature)) { panel.setSelection((AnnotatedFeatureI)feature); } } } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } } --- NEW FILE: ResultHeaderMouseListener.java --- package apollo.gui.detailviewers.sequencealigner.listeners; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Comparator; import javax.swing.JTable; import javax.swing.table.JTableHeader; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.MultiTierPanelHeaderTable; import apollo.gui.detailviewers.sequencealigner.SeqFeatureTableModel; import apollo.gui.detailviewers.sequencealigner.comparators.ComparatorFactory; public class ResultHeaderMouseListener implements MouseListener { private MultiSequenceAlignerPanel panel; private ComparatorFactory.TYPE lastSort; private int sortCount; public ResultHeaderMouseListener(MultiSequenceAlignerPanel panel) { this.panel = panel; this.sortCount = 0; } public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); Object source = e.getSource(); if (source instanceof JTableHeader) { JTableHeader tableHeader = (JTableHeader) source; MultiTierPanelHeaderTable table = (MultiTierPanelHeaderTable) tableHeader.getTable(); JTableHeader header = table.getTableHeader(); int column = header.columnAtPoint(point); SeqFeatureTableModel model = (SeqFeatureTableModel) table.getModel(); SeqFeatureTableModel.ColumnTypes colType = model.getColumnType(column); ComparatorFactory.TYPE sortType = null; if (colType == SeqFeatureTableModel.ColumnTypes.NAME) { sortType = ComparatorFactory.TYPE.NAME; } else if (colType == SeqFeatureTableModel.ColumnTypes.SCORE) { sortType = ComparatorFactory.TYPE.SCORE; } else if (colType == SeqFeatureTableModel.ColumnTypes.ID) { } else if (colType == SeqFeatureTableModel.ColumnTypes.TYPE) { sortType = ComparatorFactory.TYPE.TYPE; } else if (colType == SeqFeatureTableModel.ColumnTypes.STRAND) { } else if (colType == SeqFeatureTableModel.ColumnTypes.FRAME) { sortType = ComparatorFactory.TYPE.FRAME; } Comparator<SeqFeatureI> c = ComparatorFactory.makeComparatorSeqFeature(sortType); // toggle between normal and reverse ordering for multiple clicks on // same header if (sortType == lastSort) { if (sortCount % 2 == 0) c = ComparatorFactory.makeReverseComparator(c); sortCount++; } else { sortCount = 0; } lastSort = sortType; panel.getResultComparator().add(c); panel.reformatResultPanel(); panel.getResultPanel().repaint(); } } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } } |
From: elee <gk...@us...> - 2009-06-02 16:50:25
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/menus In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/menus Added Files: AddFilterPanel.java InsertionDialog.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AddFilterPanel.java --- package apollo.gui.detailviewers.sequencealigner.menus; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.TreeSet; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JOptionPane; import apollo.config.Config; import apollo.config.FeatureProperty; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.ReadingFrame; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.detailviewers.sequencealigner.comparators.ComparatorFactory; import apollo.gui.detailviewers.sequencealigner.comparators.ComparatorFactory.TYPE; import apollo.gui.detailviewers.sequencealigner.filters.FilterFactory; public class AddFilterPanel extends JOptionPane { private MultiSequenceAlignerPanel panel; private List<Object> values; private TYPES type; public enum TYPES { STRAND, FRAME, TYPE, SCORE, NAME }; public AddFilterPanel(MultiSequenceAlignerPanel p, TYPES t) { super(); this.panel = p; this.type = t; this.values = new ArrayList<Object>(); this.reformat(); } public void reformat() { this.setMessage("Choose a filter:"); this.setMessageType(JOptionPane.PLAIN_MESSAGE); this.setOptionType(OK_CANCEL_OPTION); updateValues(); this.setWantsInput(true); this.setSelectionValues(values.toArray()); this.setInitialSelectionValue(values.get(0)); this.selectInitialValue(); this.revalidate(); this.repaint(); } public JDialog createDialog() { return this.createDialog(panel.getParent(), "Filter Alignment Dialog"); } private void updateValues() { values.clear(); switch(type) { case FRAME: values.add(FilterFactory.makeInverse( FilterFactory.makeFilter(ReadingFrame.ONE))); values.add(FilterFactory.makeInverse( FilterFactory.makeFilter(ReadingFrame.TWO))); values.add(FilterFactory.makeInverse( FilterFactory.makeFilter(ReadingFrame.THREE))); return; case STRAND: values.add(FilterFactory.makeInverse( FilterFactory.makeFilter(Strand.FORWARD))); values.add(FilterFactory.makeInverse( FilterFactory.makeFilter(Strand.REVERSE))); return; case TYPE: TreeSet<String> types = new TreeSet<String>(); Enumeration e = Config.getPropertyScheme().getTypes(); while (e.hasMoreElements()) { String type = (String) e.nextElement(); types.add(type.toUpperCase()); } for (String type : types) { values.add(FilterFactory.makeInverse( FilterFactory.makeFilterDisplayType(type))); } return; } } } --- NEW FILE: InsertionDialog.java --- package apollo.gui.detailviewers.sequencealigner.menus; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JTextField; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import apollo.gui.detailviewers.sequencealigner.GoToDialog; public class InsertionDialog extends JDialog { /** Logger */ protected final static Logger logger = LogManager.getLogger(InsertionDialog.class); private JLabel label; private JTextField textField; public InsertionDialog(String insertion) { super(); label = new JLabel("Insertion:"); textField = new JTextField(insertion); init(); } private void init() { Box posBox = new Box(BoxLayout.X_AXIS); posBox.add(Box.createHorizontalStrut(5)); posBox.add(label); posBox.add(Box.createHorizontalStrut(10)); posBox.add(textField); posBox.add(Box.createHorizontalStrut(15)); getContentPane().add(posBox); setTitle("Insertion"); setSize(500,200); } } |
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/actions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32359/actions Added Files: AddFilterAction.java AddResultFilterAction.java CreateExonAction.java CreateIntronAction.java DeleteExonAction.java DisplaySequenceAction.java FrameShiftAction.java MergeExonAction.java SequenceEditAction.java SetEndAction.java SetTranslationStartAction.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AddFilterAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JDialog; import javax.swing.JOptionPane; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.filters.Filter; import apollo.gui.detailviewers.sequencealigner.menus.AddFilterPanel; import apollo.gui.detailviewers.sequencealigner.menus.AddFilterPanel.TYPES; public class AddFilterAction extends AbstractAction { private MultiSequenceAlignerPanel alignerPanel; private AddFilterPanel.TYPES type; public AddFilterAction(MultiSequenceAlignerPanel msap, AddFilterPanel.TYPES t) { super("Filter " + t); alignerPanel = msap; type = t; } public void actionPerformed(ActionEvent arg0) { AddFilterPanel p = new AddFilterPanel(alignerPanel, type); JDialog d = p.createDialog(); d.show(); Object type = p.getInputValue(); if (type == JOptionPane.UNINITIALIZED_VALUE) { type = null; } if (type != null) { alignerPanel.getResultFilter().add((Filter) type); alignerPanel.reformatResultPanel(); alignerPanel.getResultPanel().repaint(); alignerPanel.getOverview().updateState(); alignerPanel.getOverview().repaint(); } } } --- NEW FILE: AddResultFilterAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerPanel; import apollo.gui.detailviewers.sequencealigner.filters.Filter; public class AddResultFilterAction extends AbstractAction { private MultiSequenceAlignerPanel multiSequenceAlignerPanel; private Filter<SeqFeatureI> filter; public AddResultFilterAction(MultiSequenceAlignerPanel multiSequenceAlignerPanel) { this.multiSequenceAlignerPanel = multiSequenceAlignerPanel; this.filter = null; } public void actionPerformed(ActionEvent e) { if (filter != null) { multiSequenceAlignerPanel.getResultFilter().add(filter); multiSequenceAlignerPanel.reformatResultPanel(); multiSequenceAlignerPanel.getResultPanel().repaint(); multiSequenceAlignerPanel.getOverview().updateState(); multiSequenceAlignerPanel.getOverview().repaint(); } } public void setFilter(Filter<SeqFeatureI> filter) { this.filter = filter; } public Filter<SeqFeatureI> getFilter() { return this.filter; } } --- NEW FILE: CreateExonAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeature; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.synteny.GuiCurationState; /** * An Action class for creating a single base exon within an intron region. * * NOTE: Will this work in a non intron region? In that case the feature * would be null. For now I'll assume it won't, but maybe it should. */ public class CreateExonAction extends AbstractAction { private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature; private int basepair; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public CreateExonAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; this.setEnabled(false); } /** * Performs the insertion */ public void actionPerformed(ActionEvent e) { if (basepair < 0 || feature == null) { throw new IllegalStateException( "basepair:" + basepair + " feature:" + feature); } // TODO check that basepair falls within the bounds of an intron region SeqFeatureI temp = new SeqFeature(); temp.setStrand(feature.getStrand()); temp.setStart(basepair); temp.setEnd(basepair); // Should feature be required to have a type of Transcript? Vector<SeqFeatureI> transcripts = new Vector<SeqFeatureI>(); transcripts.addElement(feature); Vector<SeqFeatureI> exons = new Vector<SeqFeatureI>(); exons.addElement(temp); annotationEditor.setSelections(transcripts, transcripts, exons, null); annotationEditor.addExons(); curationState.getSZAP().repaint(); // TODO repaint all msa's // TODO add exon based on donor/acceptor } /** * Sets what feature the exon will be added to * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * Sets the location of the one base exon * @param basepair genomic coordinates * * The base pair should be within an intron region for the feature */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } } --- NEW FILE: CreateIntronAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.synteny.GuiCurationState; /** * An Action class for creating a single base intron within an exon region. */ public class CreateIntronAction extends AbstractAction { private GuiCurationState curationState; private AnnotationEditor annotationEditor; private int basepair; private SeqFeatureI feature; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public CreateIntronAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; this.setEnabled(false); } /** * Performs the insertion */ public void actionPerformed(ActionEvent e) { if (basepair < 0 || feature == null) { throw new IllegalStateException( "basepair:" + basepair + " feature:" + feature); } // TODO check that basepair falls within the bounds of an exon region Vector<SeqFeatureI> exons = new Vector<SeqFeatureI>(); exons.addElement(feature); annotationEditor.setSelections(basepair, -1, exons, exons, null, null); annotationEditor.splitExon(); curationState.getSZAP().repaint(); // TODO repaint all msa's // TODO Try to create intron based on donor/selector. /* // see Utils.findSplices if (Utils.notTooSmall(feature.getLow(), donor_bp) && Utils.notTooSmall(acceptor_bp, feature.getHigh())) { int low = Math.min(donor_bp, acceptor_bp); int high = Math.min(donor_bp, acceptor_bp); annotationEditor.setSelections(low, high, exons, exons, null, null); } else { // Otherwise create intron at current base annotationEditor.setSelections(basepair, -1, exons, exons, null, null); } */ } /** * Sets what feature the exon will be added to * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * Sets the location of the one base intron * @param basepair genomic coordinates * * The base pair should be within an exon region for the feature */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } } --- NEW FILE: DeleteExonAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.synteny.GuiCurationState; /** * An Action class for deleting an exon */ public class DeleteExonAction extends AbstractAction { private SeqFeatureI feature; private GuiCurationState curationState; private AnnotationEditor annotationEditor; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public DeleteExonAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.setEnabled(false); } /** * Performs the deletion */ public void actionPerformed(ActionEvent e) { if (!canExecute()) { throw new IllegalStateException("feature:" + feature); } Vector<SeqFeatureI> exons = new Vector<SeqFeatureI>(); exons.addElement(feature); annotationEditor.setSelections(exons, exons, null, null); annotationEditor.deleteSelectedFeatures(); curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets the exon which is to be deleted * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } private boolean canExecute() { return feature != null && !feature.hasKids() && feature.isExon(); } } --- NEW FILE: DisplaySequenceAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeatureI; import apollo.gui.detailviewers.seqexport.SeqExport; import apollo.gui.synteny.GuiCurationState; /** * An action class for brining up the display sequence window */ public class DisplaySequenceAction extends AbstractAction { private GuiCurationState curationState; private SeqFeatureI feature; /** * Constructor * @param name the name of this action * @param curationState the curation state */ public DisplaySequenceAction(String name, GuiCurationState curationState) { super(name); this.curationState = curationState; } /** * Brings up the display sequence window * @see apollo.gui.detailviewers.seqexport.SeqExport */ public void actionPerformed(ActionEvent arg0) { if (feature == null) { throw new IllegalStateException("feature:" + feature); } new SeqExport(feature, curationState.getController()); } /** * Sets what feature will have its sequence displayed * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } } --- NEW FILE: FrameShiftAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import apollo.datamodel.ExonI; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.synteny.GuiCurationState; /** * An Action class for performing a frame shift on a feature * * NOTE: I think that there might be some kind of limit to the number of * frame shifts allowed on a feature. */ public class FrameShiftAction extends AbstractAction { public enum FrameShiftType { PLUS1, MINUS1 }; private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature; private int basepair; private FrameShiftType shiftType; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor * @param plus1 true if this will perform a +1 frame shift */ public FrameShiftAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor, FrameShiftType shiftType) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; this.shiftType = shiftType; this.setEnabled(false); } /** * Performs the insertion */ public void actionPerformed(ActionEvent e) { // TODO check that base pair is within exon region if (basepair < 0 || feature == null || shiftType == null) { throw new IllegalStateException("basepair:" + basepair + " feature:" + feature + " shiftType:" + shiftType); } annotationEditor.setSelections(null, null, null, null); if (shiftType == FrameShiftType.PLUS1) { annotationEditor.setFrameShiftPosition((ExonI) feature, basepair, true); } else { annotationEditor.setFrameShiftPosition((ExonI) feature, basepair, false); } curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets what feature the frame shift will be added to * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * Sets the location of the frame shift * @param basepair genomic coordinates * * NOTE: Does it only make sense to have a frame shift in an exon? */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } /** * Sets the shift type for this action * @param shiftType */ public void setShiftType(FrameShiftType shiftType) { this.shiftType = shiftType; } } --- NEW FILE: MergeExonAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.synteny.GuiCurationState; /** * An Action class for merging two exons. */ public class MergeExonAction extends AbstractAction { private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature, mergeFeature; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public MergeExonAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.mergeFeature = null; this.setEnabled(false); } /** * Performs the merge */ public void actionPerformed(ActionEvent e) { // NOTE: Are there any other restraints? if (feature == null || mergeFeature == null) { throw new IllegalStateException("feature:" + feature + " mergeFeature:" + mergeFeature); } Vector<SeqFeatureI> exons = new Vector<SeqFeatureI>(); exons.addElement(feature); exons.addElement(mergeFeature); annotationEditor.setSelections(exons, exons, null, null); annotationEditor.mergeExons(); curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets first feature of the merge * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * Sets second feature of the merge * @param feature */ public void setMergeFeature(SeqFeatureI feature) { this.mergeFeature = feature; } } --- NEW FILE: SequenceEditAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Map; import javax.swing.AbstractAction; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JOptionPane; import org.bdgp.util.DNAUtils; import apollo.config.Config; import apollo.datamodel.CurationSet; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceI; import apollo.editor.AnnotationEditor; import apollo.gui.detailviewers.sequencealigner.Strand; import apollo.gui.synteny.GuiCurationState; import apollo.util.FeatureList; /** * An Action class for creating a single base sequence edit. * * The types of edits allowed are: * SequenceI.INSERTION * SequenceI.DELETION * SequenceI.SUBSTITUTION * SequenceI.CLEAR_EDIT * */ public class SequenceEditAction extends AbstractAction { /** Static Variables **/ private static Object[] opts = { "OK", "Cancel" }; private static Object[] bases = { "A", "T", "G", "C", "N", "Cancel" }; private static Object[] bases_noA = { "T", "G", "C", "N", "Cancel" }; private static Object[] bases_noT = { "A", "G", "C", "N", "Cancel" }; private static Object[] bases_noG = { "A", "T", "C", "N", "Cancel" }; private static Object[] bases_noC = { "A", "T", "G", "N", "Cancel" }; private static Map<String, Object[]> exclusionMap = new HashMap<String, Object[]>(); static { exclusionMap.put("A", bases_noA); exclusionMap.put("T", bases_noT); exclusionMap.put("G", bases_noG); exclusionMap.put("C", bases_noC); } /** Instance Variables **/ private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature; private int basepair; private String type; private JComponent parent; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public SequenceEditAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; this.type = null; this.parent = null; this.setEnabled(false); } /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor * @param type the type of sequence edit this action will perform */ public SequenceEditAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor, String type) { this(name, curationState, annotationEditor); setType(type); } /** * Performs the sequence edit */ public void actionPerformed(ActionEvent e) { // TODO check that basepair is within exon region if (basepair < 0 || feature == null) { throw new IllegalStateException("basepair:" + basepair + " feature:" + feature); } if (type.equals(SequenceI.INSERTION)) { handleInsertion(); } else if (type.equals(SequenceI.DELETION)) { handleDeletion(); } else if (type.equals(SequenceI.SUBSTITUTION)) { handleSubstitution(); } else if (type.equals(SequenceI.CLEAR_EDIT)) { handleClearEdit(); } else { throw new IllegalStateException("Unknown edit type:" + type); } curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets the feature to be edited * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * Sets the base pair to be edited * @param basepair * * NOTE: does this have to be within an exon region of a feature? * I don't think so */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } /** * Sets the type of edit which will happen * Should be one of: * SequenceI.INSERTION * SequenceI.DELETION * SequenceI.SUBSTITUTION * SequenceI.CLEAR_EDIT * * @param type */ public void setType(String type) { if (type != null && !(type.equals(SequenceI.INSERTION) || type.equals(SequenceI.DELETION) || type.equals(SequenceI.SUBSTITUTION) || type .equals(SequenceI.CLEAR_EDIT))) { throw new IllegalArgumentException("Invalid type:" + type); } this.type = type; } /** * Sets the parent component for the dialog box that pops up * @param parent */ public void setParent(JComponent parent) { this.parent = parent; } //******************************************************** // // Private Methods // //********************************************************* /** * Handler for insertions */ private void handleInsertion() { String base = getBaseFromUser("Enter base to be inserted at " + basepair, bases); if (base != null) { dealWithSequenceEdit(feature, basepair, SequenceI.INSERTION, base); } } /** * Handler for deletions */ private void handleDeletion() { dealWithSequenceEdit(feature, basepair, SequenceI.DELETION, null); } /** * Handler for substitutions */ private void handleSubstitution() { char old_base = feature.getRefSequence().getBaseAt(basepair); if (feature.getStrand() == Strand.REVERSE.toInt()) { old_base = DNAUtils.complement(old_base); } Object[] options = exclusionMap.containsKey(String.valueOf(old_base) .toUpperCase()) ? exclusionMap.get(String.valueOf(old_base) .toUpperCase()) : bases; String base = getBaseFromUser("Enter base to substitute for " + old_base + " at " + basepair, options); if (base != null) { dealWithSequenceEdit(feature, basepair, SequenceI.SUBSTITUTION, base); } } /** * Handler for edit removals */ private void handleClearEdit() { dealWithSequenceEdit(feature, basepair, SequenceI.CLEAR_EDIT, null); } /** * Prompts the user to select a base for a set of bases * * @param msg the message that the user will be prompted with * @param opts the set of bases the user can select from * @return a single character string with the selected base * * If "Cancel" is included in opts, null will be returned upon selection */ private String getBaseFromUser(String msg, Object[] opts) { JOptionPane pane = new JOptionPane(msg, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, opts, opts[0]); JDialog dialog = pane.createDialog(parent, "Please select a base"); dialog.setBackground(Config.getAnnotationBackground()); dialog.show(); String result = (String) pane.getValue(); if (result.equals("Cancel")) { result = null; } /* is there a reason for this amount of checking? */ /*if (result != null) { for (int i = 0; i < bases.length && base == null; i++) base = (bases[i].equals(result) ? (String) result : null); if (base.equals("Cancel")) base = null; }*/ return result; } /** * Does the actual sequence editing * * Deletions of seq edit come in here with operation CLEAR_EDIT */ private void dealWithSequenceEdit(SeqFeatureI feature, int basepair, String operation, String base) { /* get the list of transcripts that overlap this position */ CurationSet curation = curationState.getCurationSet(); SequenceI seq = curation.getRefSequence(); /* populates annots vector with leaf features at the current basepair */ FeatureList annots = curation.getAnnots().getLeafFeatsOver(basepair); // TODO non-exons are being returned, this shouldn't be happening // clean them out from our exon list FeatureList exons = new FeatureList(); for (int i = 0; i < annots.size(); ++i) { SeqFeatureI feat = annots.getFeature(i); if (feat.isExon()) { exons.add(feat); } } boolean approved = true; /* get approval to modify each of the exons which were not selected. * changes to all of them must be approved in order for the action to * take place.*/ for (int i = 0, size = exons.size(); i < size && approved; i++) { SeqFeatureI exon = exons.getFeature(i); if (exon != feature) { approved = getOkayFromUser(operation, exon); } } if (approved) { annotationEditor.setSequencingErrorPositions(seq, operation, basepair, base, exons); } } /** * Creates a dialog box that prompts user for aproval to perform an operation * on a feature. * * @param operation the operation to be performed * @param sf the feature which will be affected * @return true if the user oks the operation false otherwise */ private boolean getOkayFromUser(String operation, SeqFeatureI sf) { String msg = "This " + ((operation.equals(SequenceI.CLEAR_EDIT) ? "" : operation + " ") + "will affect the transcript of " + sf.getRefFeature().getName() + ". Are you sure you want to do this?"); JOptionPane pane = new JOptionPane(msg, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, opts, opts[1]); JDialog dialog = pane.createDialog(parent, "Please confirm"); dialog.show(); Object result = pane.getValue(); return result != null && opts[0].equals(result); } } --- NEW FILE: SetEndAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import java.util.Vector; import javax.swing.AbstractAction; import apollo.datamodel.SeqFeature; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.drawable.DrawableAnnotationConstants; import apollo.gui.synteny.GuiCurationState; /** * An action class for setting the start or end of a feature */ public class SetEndAction extends AbstractAction { private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature; private int basepair, terminus; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor * @param terminus Either DrawableAnnotationConstants.START or * DrawableAnnotationConstants.END or * DrawableAnnotationConstants.BOTHENDS */ public SetEndAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor, int terminus) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; setTerminus(terminus); this.setEnabled(false); } /** * Performs the update */ public void actionPerformed(ActionEvent arg0) { // TODO check that the basepair is within the bounds of an exon if (basepair < 0 || feature == null) { throw new IllegalArgumentException("basepair:" + basepair + " feature:" + feature); } SeqFeatureI temp = new SeqFeature(); temp.setStrand(feature.getStrand()); temp.setStart(basepair); temp.setEnd(basepair); Vector<SeqFeatureI> temps = new Vector<SeqFeatureI>(); temps.addElement(temp); Vector<SeqFeatureI> exons = new Vector<SeqFeatureI>(); exons.addElement(feature); annotationEditor.setSelections(exons, exons, temps, null); annotationEditor.setExonTerminus(terminus); //annotationEditor.setExonTerminus(annotationEditor.END); // set3prime //annotationEditor.setExonTerminus(annotationEditor.START); // set5prime curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets the feature which will have its start or end updated * * @param feature */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * The base which will become the new start or end * * @param basepair * * NOTE should be within the exon region of the feature. */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } /** * Sets which end will be updated * * @param terminus Either DrawableAnnotationConstants.START or * DrawableAnnotationConstants.END or * DrawableAnnotationConstants.BOTHENDS */ public void setTerminus(int terminus) { if (terminus == DrawableAnnotationConstants.START || terminus == DrawableAnnotationConstants.END || terminus == DrawableAnnotationConstants.BOTHENDS) { this.terminus = terminus; } else { throw new IllegalArgumentException("Unknown terminus:" + terminus); } } } --- NEW FILE: SetTranslationStartAction.java --- package apollo.gui.detailviewers.sequencealigner.actions; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import apollo.datamodel.ExonI; import apollo.datamodel.SeqFeatureI; import apollo.editor.AnnotationEditor; import apollo.gui.detailviewers.sequencealigner.MultiTierPanel; import apollo.gui.synteny.GuiCurationState; /** * An Action class for setting a translation start * * NOTE: I'm not really sure what this actually does. * What is a translation start? and how does it relate to the feature? * */ public class SetTranslationStartAction extends AbstractAction { private GuiCurationState curationState; private AnnotationEditor annotationEditor; private SeqFeatureI feature; private int basepair; /** * Constructor * @param name the name of this action * @param curationState the curation state * @param annotationEditor the annotation editor */ public SetTranslationStartAction(String name, GuiCurationState curationState, AnnotationEditor annotationEditor) { super(name); this.curationState = curationState; this.annotationEditor = annotationEditor; this.feature = null; this.basepair = -1; this.setEnabled(false); } /** * Performs the update */ public void actionPerformed(ActionEvent e) { // TODO check that the basepair is within the bounds of an exon if (basepair < 0 || feature == null) { throw new IllegalArgumentException("basepair:" + basepair + " feature:" + feature); } annotationEditor.setSelections(null, null, null, null); annotationEditor.setTranslationStart((ExonI) feature, basepair); curationState.getSZAP().repaint(); // TODO repaint all msa's } /** * Sets the Feature which will be affected * * @param feature should be of type apollo.datamodel.ExonI * */ public void setFeature(SeqFeatureI feature) { this.feature = feature; } /** * The base which will become the new translation start * * @param basepair * * NOTE should be within the exon region of the feature. */ public void setSelectedBasePair(int basepair) { this.basepair = basepair; } } |
From: elee <gk...@us...> - 2009-06-02 16:45:19
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/renderers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/renderers Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/renderers added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:14
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/AAPanel In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/AAPanel Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/AAPanel added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:14
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/comparators In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/comparators Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/comparators added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:12
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/models In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/models Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/models added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:12
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/menus In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/menus Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/menus added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:11
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/listeners In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/listeners Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/listeners added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:11
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/DNAPanel In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/DNAPanel Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/DNAPanel added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:11
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/actions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/actions Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/actions added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:11
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/overview In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/overview Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/overview added to the repository |
From: elee <gk...@us...> - 2009-06-02 16:45:11
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/filters In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31756/filters Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner/filters added to the repository |
From: elee <gk...@us...> - 2009-06-02 02:19:39
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15018/apollo/gui/detailviewers/sequencealigner Log Message: Directory /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner added to the repository |
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/detailviewers/sequencealigner In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15048/apollo/gui/detailviewers/sequencealigner Added Files: AbstractScrollablePanel.java AbstractTierPanel.java AminoAcidRendererOLD.java AnnotationEditorMouseListener.java AnnotationFeatureComparator.java AnnotationRighClickMenu.java BaseEditorPanel.java BaseFineEditor.java BaseFineEditorHorizontalColHeader.java BaseFineEditorRowHeader.java BaseMouseListener.java BaseRendererFactory.java CompactFeaturePlaceFinder.java DefaultBaseRenderer.java Directions.java FeaturePlaceFinder.java FeatureWrapper.java FindDialog.java GoToDialog.java HorizontalScrollBarAdjustmentListener.java MultiSequenceAlignerFrame.java MultiSequenceAlignerPanel.java MultiTierPanel.java MultiTierPanelHeaderTable.java Orientation.java PanelFactory.java ReadingFrame.java ReferenceFactory.java ReferenceFactoryI.java ReferenceTierPanelHeader.java RegionSelectableI.java ResultFeatureComparator.java ResultMouseListener.java ResultRenderer.java ResultRightClickMenu.java SelectableDNARenderer.java SemiCompactFeaturePlaceFinder.java SeqAlignPanel.java SeqFeatureTableModel.java SeqWrapper.java SequenceType.java Strand.java Tier.java TierFactory.java TierFactoryI.java TierI.java TierPanel.java TierPanelAddressHeader.java TierPanelI.java TranslationViewer.java Utils.java VerticalScrollBarAdjustmentListener.java ViewportChangeListener.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: AbstractScrollablePanel.java --- package apollo.gui.detailviewers.sequencealigner; import java.awt.Dimension; import java.awt.Rectangle; import javax.swing.JPanel; import javax.swing.Scrollable; import apollo.gui.BaseScrollable; public abstract class AbstractScrollablePanel extends JPanel implements Scrollable, BaseScrollable { } --- NEW FILE: AbstractTierPanel.java --- package apollo.gui.detailviewers.sequencealigner; import javax.swing.JPanel; public abstract class AbstractTierPanel extends JPanel implements TierPanelI { } --- NEW FILE: AminoAcidRendererOLD.java --- package apollo.gui.detailviewers.sequencealigner; // could go in detailviewers, but for now only used by exonviewer import javax.swing.*; import java.awt.*; import java.util.*; import apollo.datamodel.*; public class AminoAcidRendererOLD extends DefaultBaseRenderer { private static Hashtable colors = new Hashtable(); Color bgcolor; Color disabled = new Color(200,200,200); int phase; Font regularFont = apollo.config.Config.getExonDetailEditorSequenceFont(); Font boldFont = apollo.config.Config.getExonDetailEditorSequenceFont(); SeqAlignPanel panel; Color hatchColor; static { colors.put("M", Color.green); colors.put("*", Color.red); } public AminoAcidRendererOLD(int width, int height, int phase, SeqAlignPanel panel) { super(width,height); setFontSizes(12); this.phase = phase; this.panel = panel; } public void setFontSizes(int size) { regularFont = new Font("Courier", 0, size); boldFont = new Font("Dialog", Font.BOLD, size); } public Color getHatchColor() { return hatchColor; } public Component getBaseRendererComponent(char base, int pos, int tier, SequenceI seq) { if (panel instanceof BaseEditorPanel && ((BaseEditorPanel) panel).getShowHitZones()) { Vector hitZones = ((BaseEditorPanel) panel). getTranslatedHitZones(phase); hatchColor = null; for(int hitIndex = 0; hitZones != null && hitIndex < hitZones.size(); hitIndex++) { int [] hitZone = (int []) hitZones.elementAt(hitIndex); if (pos >= hitZone[0]*3+phase&& pos < hitZone[1]*3+phase) { hatchColor = Color.yellow; break; } } } if (colors.get(base+"") == null) setFont(regularFont); else setFont(boldFont); return super.getBaseRendererComponent(base, pos, tier, seq); } public Color getTextColor() { Color stored = (Color) colors.get(c+""); if (stored == null) return disabled; else return stored; } } --- NEW FILE: AnnotationEditorMouseListener.java --- package apollo.gui.detailviewers.sequencealigner; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import javax.swing.event.MouseInputAdapter; import org.bdgp.util.Range; import apollo.config.Config; import apollo.datamodel.ExonI; import apollo.datamodel.FeatureSetI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.Sequence; import apollo.datamodel.SequenceI; import apollo.datamodel.Transcript; import apollo.datamodel.TranslationI; import apollo.editor.AnnotationEditor; import apollo.util.ClipboardUtil; import apollo.gui.BaseScrollable; import apollo.gui.detailviewers.sequencealigner.TierI.Level; import apollo.gui.detailviewers.sequencealigner.renderers.AnnotationRenderer; import apollo.gui.detailviewers.sequencealigner.renderers.BaseRendererI; import apollo.gui.event.MouseButtonEvent; import apollo.gui.synteny.GuiCurationState; /** * Class to handle mouse interactions for an annotation panel * * NOTE: It can be hard to keep track of what coordinate system you are working * in. This should probably be cleaned up... * */ public class AnnotationEditorMouseListener extends MouseInputAdapter { public static int MIN_FEATURE_SIZE = 1; /** the curation state */ private GuiCurationState curationState; /** the scrollable object, probably a MultiSequenceAlignerPanel */ private BaseScrollable scrollableObject; /** the annotation panel */ private MultiTierPanel panel; private MultiSequenceAlignerPanel mainPanel; private SeqFeatureI dragFeature; // Don't really remember what coordinates all this stuff is in... private boolean dragging = false; private Level dragLevel = Level.BOTTOM; private int dragStartPos = -1; private int dragType = -1; /** base pair */ private int limit_3prime = -1; /** base pair */ private int limit_5prime = -1; private int pixelPos = -1; private int preDragEndBasePair=-1; private int preDragStartBasePair=-1; private int selectBeginPos = -1; private int selectCurrentPos = -1; private int startDragTier = -1; private int startPos = -1; private int tier = -1; private int tierPos = -1; private int bp = -1; /** * Constructor * * @param panel * @param curationState */ public AnnotationEditorMouseListener(MultiTierPanel panel, GuiCurationState curationState, MultiSequenceAlignerPanel mainPanel) { this.panel = panel; this.curationState = curationState; this.mainPanel = mainPanel; scrollableObject = null; dragFeature = null; dragging = false; dragLevel = Level.BOTTOM; dragStartPos = -1; dragType = -1; limit_3prime = -1; limit_5prime = -1; pixelPos = -1; preDragEndBasePair=-1; preDragStartBasePair=-1; selectBeginPos = -1; selectCurrentPos = -1; startDragTier = -1; startPos = -1; tier = -1; tierPos = -1; } /** * Calculates the (pixel) position of a given point. * * @param p the pixel coordinates of a point on the annotation panel * @return the (pixel) position that the point is on * * A pixel position represents the offset (starting with 0?) of the * base which contains this pixel. The 0th pixel position is the one * that is farthest to the left side of the screen. */ /* private int calculatePosition(Point p) { return panel.getPanel(tier).getPositionForPixel(p); } */ /** * Calculates the tier number for a given point * * @param p the pixel coordinates of a point on the annotation panel * @return the tier that the point is on */ private int calculateTierNumber(Point p) { int nonAdjustedTier = panel.tierForPixel(p); int invisibleTiers = 0; for (int i = 0; i <= nonAdjustedTier + invisibleTiers && i < panel.numTiers(); i++) { AbstractTierPanel tierPanel = panel.getPanel(i); if (!tierPanel.isVisible()) { invisibleTiers++; } } int tierNumber = nonAdjustedTier + invisibleTiers; if (tierNumber >= panel.numTiers()) { // The mouse is not over an actual tier tierNumber = 0; } return tierNumber; } /** * Updates the end of a feature if the new position is within * the given limits * * @param feature the feature to be updated * @param new_end the new end * @param limit_5prime the 5prime limit * @param limit_3prime the 3prime limit * * I think coordinates are in basepair coordinates */ private void changeEnd(SeqFeatureI feature, int new_end, int limit_5prime, int limit_3prime) { boolean okay = (panel.getStrand().equals(Strand.REVERSE) ? (new_end > limit_3prime && new_end < limit_5prime) : (new_end < limit_3prime && new_end > limit_5prime)); if (okay) { feature.setEnd(new_end); FeatureSetI parent = (FeatureSetI) feature.getRefFeature(); } } /** * Updates the start of a feature if the new position is within * the given limits * * @param feature the feature to be updated * @param new_start the new start * @param limit_5prime the 5prime limit * @param limit_3prime the 3prime limit * * I think coordinates are in basepair coordinates */ private void changeStart(SeqFeatureI feature, int new_start, int limit_5prime, int limit_3prime) { boolean okay = (panel.getStrand().equals(Strand.REVERSE) ? (new_start > limit_3prime && new_start < limit_5prime) : (new_start < limit_3prime && new_start > limit_5prime)); if (okay) { feature.setStart(new_start); FeatureSetI parent = (FeatureSetI) feature.getRefFeature(); } } /** * Creates the right click menu for the given location * * @param xLoc x pixel * @param yLoc y pixel */ private void displayRightClickMenu(int xLoc, int yLoc) { AnnotationRighClickMenu rightClickMenu = new AnnotationRighClickMenu(curationState, panel); rightClickMenu.setScrollableObject(this.getScrollableObject()); rightClickMenu.formatRightClickMenu(tierPos, bp, tier); // Keep the menu from falling off the edge of the screen if (xLoc >= panel.getSize().width/2) // We're on the right side of the screen // Move the popup to the left of the cursor xLoc = xLoc - rightClickMenu.getPreferredSize().width; else // Move the popup to the right of the cursor, plus a small nudge xLoc = xLoc + 10; if (yLoc + rightClickMenu.getPreferredSize().height > panel.getSize().height) yLoc = yLoc - ((yLoc + rightClickMenu.getPreferredSize().height) - panel.getSize().height); rightClickMenu.show(panel,xLoc,yLoc); } /** * Gets the annotation editor. * * @return an annotation editor */ public AnnotationEditor getAnnotationEditor() { return curationState.getAnnotationEditor(panel.getStrand().equals(Strand.FORWARD)); } /** * Gets the current (pixel) position * @return */ /* public int getPos() { return pixelPos; } */ /** * */ /* public int getBasepair() { return panel.tierPositionToBasePair(tierPos); } */ /** * Gets the scrollable object that will be affected * * @return */ public BaseScrollable getScrollableObject() { return this.scrollableObject; } /** * Gets the current tier * * @return */ public int getTier() { return tier; } /** * Handles the mouse click events * * Middle mouse scrolls to where clicked * Left mouse selects a feature * Right mouse brings up popup menu */ public void mouseClicked(MouseEvent e) { // update the current position setPos(e.getX(), e.getY()); if (MouseButtonEvent.isRightMouseClickNoShift(e)) { displayRightClickMenu(e.getX(), e.getY()); } if (MouseButtonEvent.isMiddleMouseClickNoShift(e) || MouseButtonEvent.isRightMouseClickWithShift(e)) { this.scrollableObject.scrollToBase(bp); //panel.scrollToPosition(pixelPos); //this.scrollableObject.scrollToBase(getBasepair()); } if (MouseButtonEvent.isLeftMouseClick(e)) { selectAnnot(tierPos, tier); panel.repaint(); } } /** * Handles the mouse drag events * * Left mouse dragging drags end of feature * if drag type right or left boundary. * DragType is figured in mousePressed * * TODO clean up! */ public void mouseDragged(MouseEvent e) { if (!MouseButtonEvent.isLeftMouseClick(e)) return; setPos(e.getX(), e.getY()); // scrolls window when dragging at boundaries scroll(e.getX(), e.getY()); // dragFeature set in mousePressed if (dragging == false && dragFeature != null) { //not needed? //changer = baseEditorPanel.getAnnotationEditor().beginRangeChange(dragFeature); // ?? preDragStartBasePair = dragFeature.getStart(); preDragEndBasePair = dragFeature.getEnd(); } dragging = true; // dragType determined in MousePressed if (dragType == BaseEditorPanel.SEQ_SELECT_DRAG) { // Set the cursor // TODO: move to own method? panel.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); int redrawLowPos = selectLowPos(); int redrawHighPos = selectHighPos(); if (pixelPos < redrawLowPos) redrawLowPos = pixelPos; if (pixelPos > redrawHighPos) redrawHighPos = pixelPos; setSelectCurrentPos(pixelPos); BaseRendererI rend = panel.getPanel(tier).getRenderer(); if (rend instanceof RegionSelectableI) { for (int i = 0; i < panel.getPanels().size(); i++) { TierPanelI p = panel.getPanel(i); BaseRendererI r = p.getRenderer(); int po = getTierPosition(e.getX(), e.getY(), i); ((RegionSelectableI) r).setRegionEnd(po); } } panel.repaint(); return; } else if (dragFeature != null) { // dragType is a boundary change //TODO handle drag when not holding any other buttons int dfPixelStartPos = panel.getPanel(tier).tierPositionToPixelPosition( panel.getTier(tier).getPosition(dragFeature.getStart())); int dfPixelEndPos = panel.getPanel(tier).tierPositionToPixelPosition( panel.getTier(tier).getPosition(dragFeature.getEnd())); //int pixelPosBP = getBasePair(e.getX(), e.getY(), tier); int pixelPosBP = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(pixelPos)); if (panel.getTier(0).getType() == SequenceType.AA) { if (dragType == SeqAlignPanel.START_BOUNDARY) { int start = dragFeature.getStart(); int nextBpInFrame = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(dfPixelStartPos+1)); int offset = Math.abs(nextBpInFrame - start); pixelPosBP -= (offset*dragFeature.getStrand()); } else if (dragType == SeqAlignPanel.END_BOUNDARY) { int end = dragFeature.getEnd(); int prevBpInFrame = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(dfPixelEndPos-1)); int offset = Math.abs(end - prevBpInFrame); pixelPosBP += (offset*dragFeature.getStrand()); } } if (dragType == SeqAlignPanel.START_BOUNDARY) { panel.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); if (notTooSmall(pixelPos, dfPixelEndPos)) changeStart(dragFeature, pixelPosBP,limit_5prime, limit_3prime); } else if (dragType == SeqAlignPanel.END_BOUNDARY) { panel.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); if (notTooSmall(dfPixelStartPos, pixelPos)) changeEnd(dragFeature, pixelPosBP,limit_5prime,limit_3prime); } } // repaint with exon seq feature ends changed //baseEditorPanel.repaint(pos, dragStartPos); panel.repaint(); dragStartPos = pixelPos; } /** makes cursor hand if at the end of an exon using mouses position, does not change pos or tier variable */ public void mouseMoved(MouseEvent e) { // setPos sets the pos variable to the mouse position, cant do this // because on right click menu want to preserve the pos clicked on // and setPos here changes pos if user moves mouse after right click //setPos (e.getX(), e.getY()); // moveMouseTier and moveMousePos can differ from this.tier and pos Point p = new Point(e.getX(), e.getY()); //int mouseMoveTier = baseEditorPanel.getTierForPixelPosition(e.getY()); //SeqAlignPanel //int mouseMovePos = calculatePosition(e.getX(), e.getY()); int mouseMoveTier = calculateTierNumber(p); int mouseMovePos = getTierPosition(e.getX(), e.getY(), mouseMoveTier); //int mouseMovePos = panel.pixelPositionToTierPosition(calculatePosition(p)); // make the cursor a hand if it is at the end of a feature int type = panel.getTier(mouseMoveTier).getBoundaryType(mouseMovePos, TierI.Level.BOTTOM); if (type == SeqAlignPanel.NO_BOUNDARY) type = panel.getTier(mouseMoveTier).getBoundaryType(mouseMovePos, TierI.Level.TOP); if (!e.isShiftDown() && type == SeqAlignPanel.NO_BOUNDARY) panel.setCursor(Cursor.getDefaultCursor()); else if (e.isShiftDown()) panel.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); else panel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } /** Right mouse: highlight base. Left mouse: figure dragType, dragFeature, dragStartPos, startDragTier */ public void mousePressed(MouseEvent e) { setPos(e.getX(), e.getY()); BaseRendererI rend = panel.getPanel(tier).getRenderer(); if (rend instanceof RegionSelectableI) { for (TierPanelI p : panel.getPanels()) { BaseRendererI r = p.getRenderer(); ((RegionSelectableI) r).setRegionStart(-1); ((RegionSelectableI) r).setRegionEnd(-1); } panel.repaint(); } // show base at right mouse click highlighted (on release - popup menu) if (MouseButtonEvent.isRightMouseClickNoShift(e)) { if (rend instanceof RegionSelectableI) { //int target = panel.getModelTierPanel().pixelPositionToTierPosition(pixelPos); //for (TierPanelI p : panel.getPanels()) { for (int i = 0; i < panel.getPanels().size(); i++) { TierPanelI p = panel.getPanel(i); BaseRendererI r = p.getRenderer(); int tierPosition = getTierPosition(e.getX(),e.getY(),i); ((RegionSelectableI) r).setRegionStart(tierPosition); ((RegionSelectableI) r).setRegionEnd(tierPosition); } panel.repaint(); return; } } if (!MouseButtonEvent.isLeftMouseClick(e)) return; // drag has not started if (dragStartPos == -1) { if (e.isShiftDown()) { dragType = BaseEditorPanel.SEQ_SELECT_DRAG; // copying sequence } else { dragType = panel.getTier(tier).getBoundaryType(tierPos, TierI.Level.BOTTOM); dragFeature = panel.getTier(tier).featureAt(tierPos, Tier.Level.BOTTOM); dragLevel = Level.BOTTOM; } if (dragType == SeqAlignPanel.NO_BOUNDARY) { dragType = panel.getTier(tier).getBoundaryType(tierPos, TierI.Level.TOP); dragFeature = panel.getTier(tier).featureAt(tierPos, TierI.Level.TOP); dragLevel = Level.TOP; } //if (dragType == SeqAlignPanel.NO_BOUNDARY) { // dragType = BaseEditorPanel.SEQ_SELECT_DRAG; //} dragStartPos = pixelPos; startPos = pixelPos; startDragTier = tier; if (dragFeature == null && ((dragType != BaseEditorPanel.SEQ_SELECT_DRAG) || startDragTier >= panel.numTiers())) { resetDragState(); return; } // What is this doing? if (dragType == SeqAlignPanel.START_BOUNDARY) { /* the 5 prime edge of the feature (exon) can be moved within limits. These are no farther in the 3prime direction than the end of the feature and no farther in the 5prime direction than the end of the preceding exon */ limit_3prime = dragFeature.getEnd(); int dfStartPos = panel.basePairToTierPosition(dragFeature.getStart()); SeqFeatureI precedingFeature = panel.getTier(tier).getPrevFeature(dfStartPos, dragLevel); if (precedingFeature == null) { limit_5prime = panel.tierPositionToBasePair(0); } else { limit_5prime = precedingFeature.getEnd() + (1 * precedingFeature.getStrand()); // keep the intron } panel.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); } else if (dragType == SeqAlignPanel.END_BOUNDARY) { limit_5prime = dragFeature.getStart(); int dfEndPos = panel.basePairToTierPosition(dragFeature.getEnd()); SeqFeatureI nextFeature = panel.getTier(tier).getNextFeature(dfEndPos, dragLevel); if (nextFeature == null) { SequenceI seq = panel.getTier(tier).getReference(); limit_3prime = panel.tierPositionToBasePair(seq.getLength()-1); } else { limit_3prime = nextFeature.getStart() - (1 * nextFeature.getStrand()); // keep the intron; } panel.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); } else if (dragType == BaseEditorPanel.SEQ_SELECT_DRAG) { panel.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); selectBeginPos = pixelPos; selectCurrentPos = pixelPos; if (rend instanceof RegionSelectableI) { for (int i = 0; i < panel.getPanels().size(); i++) { TierPanelI p = panel.getPanels().get(i); BaseRendererI r = p.getRenderer(); int pos = getTierPosition(e.getX(),e.getY(),i); ((RegionSelectableI) r).setRegionStart(pos); ((RegionSelectableI) r).setRegionEnd(pos); } panel.repaint(); } } } } /** If right mouse deselect base If end of feature drag notify AnnotationEditor (endRangeChange) and recalc translation end from start */ public void mouseReleased(MouseEvent e) { // RIGHT MOUSE CLICK if (MouseButtonEvent.isRightMouseClick(e)) { BaseRendererI rend = panel.getPanel(tier).getRenderer(); if (rend instanceof RegionSelectableI) { for (TierPanelI p : panel.getPanels()) { BaseRendererI r = p.getRenderer(); ((RegionSelectableI) r).setRegionStart(-1); ((RegionSelectableI) r).setRegionEnd(-1); } panel.repaint(); return; } } // SEQ SELECT DRAG if (dragType == BaseEditorPanel.SEQ_SELECT_DRAG) { SequenceI seq = panel.getTier(startDragTier).getReference(); int lowBP = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(selectLowPos())); int highBP = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(selectHighPos())); if (lowBP > highBP) { int temp = lowBP; lowBP = highBP; highBP = temp; } String sequence = seq.getResidues(lowBP, highBP); int start = lowBP; int end = highBP; if (seq.getRange().getStrand() == -1) { start = highBP; end = lowBP; } String header = " Arbitrary selection ("+seq.getName()+": "+ start + "," + end + ") "; //controllingWindow.copySeqToClipboard(new Sequence (header, sequence)); ClipboardUtil.copySeqToClipboard(new Sequence(header,sequence)); resetDragState(); panel.repaint(); return; } // NOT SEQ SELECT DRAG else { // NOT DRAGGING - RETURN if (!MouseButtonEvent.isLeftMouseClick(e) || !dragging || dragFeature == null) { resetDragState(); return; } // DRAGGING ANNOT ENDS if (dragging && dragFeature != null && dragFeature.isAnnot()) { // NOTIFY ANNOTATION EDITOR (generates transaction) int oldStart = (preDragStartBasePair==-1) ? dragFeature.getStart() : preDragStartBasePair; int oldEnd = (preDragEndBasePair==-1) ? dragFeature.getEnd() : preDragEndBasePair; AnnotationEditor ae = getAnnotationEditor(); ae.setAnnotTerminus(dragFeature.getAnnotatedFeature(),oldStart,oldEnd, dragFeature.getStart(),dragFeature.getEnd()); recalcCDS(dragFeature); panel.repaint(); } } resetDragState(); curationState.getSZAP().repaint(); } public static void recalcCDS(SeqFeatureI feature) { // RECALC CDS (if exon/transcript - not for 1 level annots) if (feature.isExon() && feature.getRefFeature() != null && (feature.getRefFeature().isTranscript())) { //ExonI exon = (ExonI)dragFeature; //Transcript t = (Transcript)exon.getRefFeature(); SeqFeatureI transcript = feature.getRefFeature(); TranslationI cds = transcript.getTranslation(); int transStart = transcript.getStart(); int cdsStart = cds.getTranslationStart(); boolean isForward = transcript.isForwardStrand(); if (cds.isMissing5prime() && ((isForward && transStart < cdsStart) || (!isForward && transStart > cdsStart)) ) { cds.calcTranslationStartForLongestPeptide(); // missing start } else { cds.setTranslationEndFromStart(); // got start - set end } } } protected void resetDragState() { panel.setCursor(Cursor.getDefaultCursor()); dragStartPos = -1; dragType = -1; // These are min and max in genomic coord. space limit_5prime = -1; limit_3prime = -1; selectBeginPos = -1; selectCurrentPos = -1; dragFeature = null; dragging = false; preDragStartBasePair = -1; preDragEndBasePair = -1; } /** * Selects the feature at a given pos/tier. * * Called on internal selection. * Both fires off selection event and shows feature selected. */ void selectAnnot(int pos, int tier) { //SeqFeatureI sf = panel.getTier(tier).featureAt(pos, TierI.Level.TOP); SeqFeatureI sf = panel.getTier(tier).featureAt(pos, TierI.Level.BOTTOM); if (sf == null) { sf = panel.getTier(tier).getNextFeature(pos, TierI.Level.BOTTOM); } //showAnnotSelected(sf, tier); // TODO add red box around selected // selection manager select fires event if (sf!=null) curationState.getSelectionManager().select(sf, this); } public int selectHighPos() { return (selectBeginPos > selectCurrentPos ? selectBeginPos : selectCurrentPos); } public int selectLowPos() { return (selectBeginPos < selectCurrentPos ? selectBeginPos : selectCurrentPos); } /** * Updates the necessary position state * * @param x * @param y */ private void setPos(int x, int y) { Point p = new Point(x, y); this.tier = calculateTierNumber(p); this.pixelPos = getPixelPosition(x, y, tier); this.tierPos = getTierPosition(x, y, tier); this.bp = getBasePair(x, y, tier); } private int getPixelPosition(int x, int y, int t) { Point p = new Point(x,y); return panel.getPanel(t).getPositionForPixel(p); } private int getTierPosition(int x, int y, int t) { Point p = new Point(x,y); int pixelPosition = panel.getPanel(t).getPositionForPixel(p); int tierPosition = panel.getPanel(t).pixelPositionToTierPosition(pixelPosition); int bp = panel.getTier(t).getBasePair(tierPosition); if (panel.getTier(t).getType() == SequenceType.AA) { int offset = AnnotationRenderer.getOffset(tierPosition, panel.getTier(t)); bp += offset*panel.getTier(t).getStrand().toInt(); tierPosition = panel.getTier(t).getPosition(bp); } return tierPosition; } private int getBasePair(int x, int y, int t) { Point p = new Point(x,y); int pixelPosition = panel.getPanel(t).getPositionForPixel(p); int tierPosition = panel.getPanel(t).pixelPositionToTierPosition(pixelPosition); int bp = panel.getTier(t).getBasePair(tierPosition); if (panel.getTier(t).getType() == SequenceType.AA) { int offset = AnnotationRenderer.getOffset(tierPosition, panel.getTier(t)); bp += offset*panel.getTier(t).getStrand().toInt(); tierPosition = panel.getTier(t).getPosition(bp); } return bp; } public void setScrollableObject(BaseScrollable scrollableObject) { this.scrollableObject = scrollableObject; } void setSelectBeginPos(int sbp) { this.selectBeginPos = sbp; } void setSelectCurrentPos(int scp) { this.selectCurrentPos = scp; } /** * returns true if the distance between the two end points (inclusive) is * greater than or equal to MIN_FEATURE_SIZE */ public static boolean notTooSmall (int start_pos, int end_pos) { return Math.abs(end_pos - start_pos) + 1 >= MIN_FEATURE_SIZE; } public void scroll(int x, int y) { int bp = mainPanel.getVisibleBase(); Rectangle rect = mainPanel.getAnnotationPane().getViewport().getViewRect(); int startPixPos = panel.getPanel(tier).tierPositionToPixelPosition( panel.basePairToTierPosition(bp)); int endPixPos = startPixPos + rect.width/panel.getBaseWidth(); if (getPixelPosition(x,y,tier) >= endPixPos-1) { scrollRight(); } else if (getPixelPosition(x,y,tier) <= startPixPos+1){ scrollLeft(); } } public void scrollLeft() { int bp = mainPanel.getVisibleBase(); int startPixPos = panel.getPanel(tier).tierPositionToPixelPosition( panel.basePairToTierPosition(bp)); int base = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(startPixPos-1)); mainPanel.scrollToBase(base); } public void scrollRight() { int bp = mainPanel.getVisibleBase(); int startPixPos = panel.getPanel(tier).tierPositionToPixelPosition( panel.basePairToTierPosition(bp)); int base = panel.tierPositionToBasePair( panel.pixelPositionToTierPosition(startPixPos+1)); mainPanel.scrollToBase(base); } } --- NEW FILE: AnnotationFeatureComparator.java --- package apollo.gui.detailviewers.sequencealigner; import java.util.Comparator; import apollo.datamodel.SeqFeatureI; public class AnnotationFeatureComparator implements Comparator { public int compare(Object o1, Object o2) { SeqFeatureI f1 = (SeqFeatureI) o1; SeqFeatureI f2 = (SeqFeatureI) o2; // the feature lengths int l1 = f1.getHigh() - f1.getLow() + 1; int l2 = f2.getHigh() - f2.getLow() + 1; int result = 0; if (l1 < l2) { result = 1; } else if (l1 > l2) { result = -1; } else { result = f1.getName().compareToIgnoreCase(f2.getName()); } return result; } } --- NEW FILE: AnnotationRighClickMenu.java --- package apollo.gui.detailviewers.sequencealigner; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import org.bdgp.util.Range; import apollo.config.Config; import apollo.datamodel.ExonI; import apollo.datamodel.FeatureSetI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.SequenceEdit; import apollo.datamodel.SequenceI; import apollo.editor.AnnotationEditor; import apollo.gui.BaseScrollable; import apollo.gui.detailviewers.sequencealigner.actions.CreateExonAction; import apollo.gui.detailviewers.sequencealigner.actions.CreateIntronAction; import apollo.gui.detailviewers.sequencealigner.actions.DeleteExonAction; import apollo.gui.detailviewers.sequencealigner.actions.DisplaySequenceAction; import apollo.gui.detailviewers.sequencealigner.actions.FrameShiftAction; import apollo.gui.detailviewers.sequencealigner.actions.MergeExonAction; import apollo.gui.detailviewers.sequencealigner.actions.SequenceEditAction; import apollo.gui.detailviewers.sequencealigner.actions.SetEndAction; import apollo.gui.detailviewers.sequencealigner.actions.SetTranslationStartAction; import apollo.gui.synteny.GuiCurationState; /** * This is the popup menu that gets displayed when you right click on an * annotation. */ public class AnnotationRighClickMenu extends JPopupMenu { private static final int MIN_FEATURE_SIZE = 1; /** This should be the Annotation window */ private MultiTierPanel panel; /** The curation state */ private GuiCurationState curationState; // TODO fix how this is done! // It would be nice to remove this dependency if possible /** This should be reference to the main MultiSequenceAlignerPanel */ private BaseScrollable scrollableObject; // The Actions private CreateIntronAction createIntronAction; private CreateExonAction createExonAction; private DeleteExonAction deleteExonAction; private FrameShiftAction plus1FrameShiftAction; private FrameShiftAction minus1FrameShiftAction; private SetTranslationStartAction setTranslationStartAction; private MergeExonAction merge5PrimeAction; private MergeExonAction merge3PrimeAction; private SetEndAction set5PrimeAction; private SetEndAction set3PrimeAction; private SequenceEditAction insertionAction; private SequenceEditAction deletionAction; private SequenceEditAction substitutionAction; private SequenceEditAction removeAdjustmentAction; private DisplaySequenceAction displaySequenceAction; private AbstractAction displayFindAction; private AbstractAction displayGoToAction; // The Lables private JLabel locationLabel; private JLabel relativeLocationLabel; // The menu items protected JMenuItem creaateIntronMenuItem; protected JMenuItem createExonMenuItem; protected JMenuItem merge5PrimeMenuItem; protected JMenuItem merge3PrimeMenuItem; protected JMenuItem set5PrimeMenuItem; protected JMenuItem set3PrimeMenuItem; protected JMenuItem deleteExonMenuItem; protected JMenuItem setTranslationStartMenuItem; protected JMenuItem plus1FrameShiftMenuItem; protected JMenuItem minus1FrameShiftMenuItem; protected JMenuItem insertionMenuItem; protected JMenuItem deletionMenuItem; protected JMenuItem substitutionMenuItem; protected JMenuItem removeAdjustmentMenuItem; protected JMenu sequencingErrorSubMenu; protected JMenuItem findSequenceMenuItem; protected JMenuItem displaySequenceMenuItem; protected JMenuItem goToMenuItem; /** * Constructor * * @param curationState * @param panel should be the annotation panel */ public AnnotationRighClickMenu(GuiCurationState curationState, MultiTierPanel panel) { super(); this.scrollableObject = null; this.curationState = curationState; this.panel = panel; init(); } /** * Gets the scrollable object for this menu * * @return */ public BaseScrollable getScrollableObject() { return this.scrollableObject; } /** * Sets the scrollable object for this menu * * @param scrollableObject this is the object that will be affected by * the "Find Sequence" and "Go To" actions */ public void setScrollableObject(BaseScrollable scrollableObject) { this.scrollableObject = scrollableObject; } /** * Updates menu to reflect the options available at the given position and * tier. * * @param pos - tier position * @param tier */ public void formatRightClickMenu(int pos, int dnapos, int tier) { disableAllActions(); // Get the relevant features SeqFeatureI feature = panel.getTier(tier) .featureAt(pos, TierI.Level.BOTTOM); if (feature == null) { feature = panel.getTier(tier).featureAt(pos, TierI.Level.TOP); } SeqFeatureI nextFeature = panel.getTier(tier).getNextFeature(pos, TierI.Level.BOTTOM); SeqFeatureI prevFeature = panel.getTier(tier).getPrevFeature(pos, TierI.Level.BOTTOM); //int dnapos = panel.tierPositionToBasePair(pos); // Setup the actions createIntronAction.setFeature(feature); createIntronAction.setSelectedBasePair(dnapos); createExonAction.setFeature(feature); createExonAction.setSelectedBasePair(dnapos); deleteExonAction.setFeature(feature); plus1FrameShiftAction.setFeature(feature); plus1FrameShiftAction.setSelectedBasePair(dnapos); minus1FrameShiftAction.setFeature(feature); minus1FrameShiftAction.setSelectedBasePair(dnapos); setTranslationStartAction.setFeature(feature); setTranslationStartAction.setSelectedBasePair(dnapos); merge5PrimeAction.setFeature(feature); merge5PrimeAction.setMergeFeature(prevFeature); merge3PrimeAction.setFeature(feature); merge3PrimeAction.setMergeFeature(nextFeature); set5PrimeAction.setFeature(feature); set5PrimeAction.setSelectedBasePair(dnapos); set3PrimeAction.setFeature(feature); set3PrimeAction.setSelectedBasePair(dnapos); insertionAction.setFeature(feature); insertionAction.setSelectedBasePair(dnapos); insertionAction.setParent(panel); insertionAction.setType(SequenceI.INSERTION); deletionAction.setFeature(feature); deletionAction.setSelectedBasePair(dnapos); deletionAction.setParent(panel); deletionAction.setType(SequenceI.DELETION); substitutionAction.setFeature(feature); substitutionAction.setSelectedBasePair(dnapos); substitutionAction.setParent(panel); substitutionAction.setType(SequenceI.SUBSTITUTION); removeAdjustmentAction.setFeature(feature); removeAdjustmentAction.setSelectedBasePair(dnapos); removeAdjustmentAction.setParent(panel); removeAdjustmentAction.setType(SequenceI.CLEAR_EDIT); displaySequenceAction.setFeature(feature); // Set up the Labels locationLabel.setText(" Location = " + dnapos); if (feature != null) { if (feature instanceof ExonI) { FeatureSetI fs = (FeatureSetI) feature.getRefFeature(); // transcript int feat_index = fs.getFeatureIndex(feature); int mRNA_loc = (int) fs.getFeaturePosition(dnapos); int exon_loc = (int) feature.getFeaturePosition(dnapos); relativeLocationLabel.setText(" Base " + exon_loc + " of exon " + (feat_index + 1) + " mRNA base " + mRNA_loc); } else { int trans_loc = (int) feature.getStart() + (dnapos * feature.getStrand()); relativeLocationLabel .setText(" Base " + trans_loc + " of transcript"); } } else { relativeLocationLabel.setText(" No feature at position"); relativeLocationLabel.setEnabled(false); } // Enable all actions which are possible at this position if (this.scrollableObject != null) { this.displayGoToAction.setEnabled(true); this.displayFindAction.setEnabled(true); } if (feature != null) { int start_pos = panel.basePairToTierPosition(feature.getStart()); int end_pos = panel.basePairToTierPosition(feature.getEnd()); displaySequenceAction.setEnabled(true); if (feature.hasKids()) { // cursor is between exons (on an intron) Range intronRange = panel.getTier(tier) .rangeAt(pos, TierI.Level.BOTTOM); createExonAction.setEnabled(dnapos != intronRange.getLow() && dnapos != intronRange.getHigh()); } else { // feature has no children -> courser is on an exon or 1 level annot boolean isExon = feature.isExon(); Range exonRange = panel.getTier(tier).rangeAt(pos, TierI.Level.BOTTOM); FeatureSetI fs = (FeatureSetI) feature.getRefFeature(); createIntronAction.setEnabled(isExon && dnapos != exonRange.getLow() && dnapos != exonRange.getHigh()); deleteExonAction.setEnabled(isExon); engagePlus1FrameShiftMenuItem(isExon, fs, dnapos); engageMinus1FrameShiftMenuItem(isExon, fs, dnapos); setTranslationStartAction.setEnabled(isExon); this.merge5PrimeMenuItem.setEnabled(prevFeature != null && prevFeature.getRefFeature() == feature.getRefFeature()); this.merge3PrimeMenuItem.setEnabled(nextFeature != null && nextFeature.getRefFeature() == feature.getRefFeature()); set5PrimeAction.setEnabled(pos != start_pos && notTooSmall(pos, end_pos)); set3PrimeAction.setEnabled(pos != end_pos && notTooSmall(start_pos, pos)); // actually deleting is buggy for both exons & 1 level annots // the delete is going through but ede is not letting go of deleted feat // or not refreshing properly or something if (Config.getStyle().seqErrorEditingIsEnabled() && panel.getType() == SequenceType.DNA) sequencingErrorMenuItem(fs, dnapos); } } } /** * Initializes the menu */ private void init() { /* Create Actions */ createActions(); disableAllActions(); /* Create Menu Items */ createMenuItems(); /* Create Menu */ add(locationLabel); add(relativeLocationLabel); addSeparator(); add(displaySequenceMenuItem); add(findSequenceMenuItem); add(goToMenuItem); addSeparator(); add(creaateIntronMenuItem); add(createExonMenuItem); add(deleteExonMenuItem); add(merge5PrimeMenuItem); add(merge3PrimeMenuItem); add(set5PrimeMenuItem); add(set3PrimeMenuItem); add(setTranslationStartMenuItem); if (panel.getType() == SequenceType.DNA) { addSeparator(); if (Config.getStyle().translationalFrameShiftEditingIsEnabled()) { add(plus1FrameShiftMenuItem); add(minus1FrameShiftMenuItem); } if (Config.getStyle().seqErrorEditingIsEnabled()) add(sequencingErrorSubMenu); } } /** * Creates all of the actions */ private void createActions() { createIntronAction = new CreateIntronAction("Create intron", curationState, getEditor()); createExonAction = new CreateExonAction("Create exon", curationState, getEditor()); deleteExonAction = new DeleteExonAction("Delete exon", curationState, getEditor()); plus1FrameShiftAction = new FrameShiftAction( "Set +1 translation frame shift here", curationState, getEditor(), FrameShiftAction.FrameShiftType.PLUS1); minus1FrameShiftAction = new FrameShiftAction( "Set -1 translation frame shift here", curationState, getEditor(), FrameShiftAction.FrameShiftType.MINUS1); setTranslationStartAction = new SetTranslationStartAction( "Set start of translation", curationState, getEditor()); merge5PrimeAction = new MergeExonAction("Merge with 5' exon", curationState, getEditor()); merge3PrimeAction = new MergeExonAction("Merge with 3' exon", curationState, getEditor()); set5PrimeAction = new SetEndAction("Set as 5' end", curationState, getEditor(), getEditor().START); set3PrimeAction = new SetEndAction("Set as 3' end", curationState, getEditor(), getEditor().END); insertionAction = new SequenceEditAction("Insert", curationState, getEditor(), SequenceI.INSERTION); deletionAction = new SequenceEditAction("Delete", curationState, getEditor(), SequenceI.DELETION); substitutionAction = new SequenceEditAction("Substitute", curationState, getEditor(), SequenceI.SUBSTITUTION); removeAdjustmentAction = new SequenceEditAction("Remove Adjustment", curationState, getEditor(), SequenceI.CLEAR_EDIT); displaySequenceAction = new DisplaySequenceAction("Display Sequence", curationState); displayFindAction = new AbstractAction("Find Sequence") { public void actionPerformed(ActionEvent arg0) { FindDialog fd = new FindDialog(getScrollableObject(), panel, panel .getTier(0).getReference(), panel.getStrand() == Strand.REVERSE); fd.show(); } }; displayGoToAction = new AbstractAction("Go To") { public void actionPerformed(ActionEvent arg0) { GoToDialog gt = new GoToDialog(getScrollableObject()); gt.show(); } }; } /** * Creates all of the menu items */ private void createMenuItems() { locationLabel = new JLabel("Location"); relativeLocationLabel = new JLabel("Relative location"); displaySequenceMenuItem = new JMenuItem(displaySequenceAction); creaateIntronMenuItem = new JMenuItem(createIntronAction); createExonMenuItem = new JMenuItem(createExonAction); deleteExonMenuItem = new JMenuItem(deleteExonAction); plus1FrameShiftMenuItem = new JMenuItem(plus1FrameShiftAction); minus1FrameShiftMenuItem = new JMenuItem(minus1FrameShiftAction); setTranslationStartMenuItem = new JMenuItem(setTranslationStartAction); merge5PrimeMenuItem = new JMenuItem(merge5PrimeAction); merge3PrimeMenuItem = new JMenuItem(merge3PrimeAction); set5PrimeMenuItem = new JMenuItem(set5PrimeAction); set3PrimeMenuItem = new JMenuItem(set3PrimeAction); insertionMenuItem = new JMenuItem(insertionAction); deletionMenuItem = new JMenuItem(deletionAction); substitutionMenuItem = new JMenuItem(substitutionAction); removeAdjustmentMenuItem = new JMenuItem(removeAdjustmentAction); sequencingErrorSubMenu = new JMenu("Adjust for sequencing error here"); sequencingErrorSubMenu.add(insertionMenuItem); sequencingErrorSubMenu.add(deletionMenuItem); sequencingErrorSubMenu.add(substitutionMenuItem); this.findSequenceMenuItem = new JMenuItem(displayFindAction); this.goToMenuItem = new JMenuItem(displayGoToAction); } /** * Sets all of the actions to be disabled */ private void disableAllActions() { createIntronAction.setEnabled(false); createExonAction.setEnabled(false); deleteExonAction.setEnabled(false); plus1FrameShiftAction.setEnabled(false); minus1FrameShiftAction.setEnabled(false); setTranslationStartAction.setEnabled(false); merge5PrimeAction.setEnabled(false); merge3PrimeAction.setEnabled(false); set5PrimeAction.setEnabled(false); set3PrimeAction.setEnabled(false); insertionAction.setEnabled(false); deletionAction.setEnabled(false); substitutionAction.setEnabled(false); removeAdjustmentAction.setEnabled(false); displaySequenceAction.setEnabled(false); displayGoToAction.setEnabled(false); displayFindAction.setEnabled(false); } /** * Format the menu item for plus1 frame shifts * @param isExon * @param fs * @param dnapos */ private void engagePlus1FrameShiftMenuItem(boolean isExon, FeatureSetI fs, int dnapos) { plus1FrameShiftAction.setSelectedBasePair(dnapos); plus1FrameShiftMenuItem.setText("Set +1 translational frame shift here"); if (isExon && fs.withinCDS(dnapos) && !isSequencingErrorPosition(dnapos) && fs.minus1FrameShiftPosition() != dnapos) { plus1FrameShiftAction.setEnabled(true); if (dnapos == fs.plus1FrameShiftPosition()) { plus1FrameShiftAction.setSelectedBasePair(0); // setting to 0 removes shift plus1FrameShiftMenuItem .setText("Remove +1 translational frame shift here"); } } } /** * Format the menu item for minus1 frame shifts * @param isExon * @param fs * @param dnapos */ private void engageMinus1FrameShiftMenuItem(boolean isExon, FeatureSetI fs, int dnapos) { minus1FrameShiftAction.setSelectedBasePair(dnapos); minus1FrameShiftMenuItem.setText("Set -1 translational frame shift here"); if (isExon && fs.withinCDS(dnapos) && !isSequencingErrorPosition(dnapos) && fs.plus1FrameShiftPosition() != dnapos) { minus1FrameShiftAction.setEnabled(true); if (dnapos == fs.minus1FrameShiftPosition()) { minus1FrameShiftAction.setSelectedBasePair(0); minus1FrameShiftMenuItem .setText("Remove -1 translational frame shift here"); } } } /** * Format the menu item for sequence adjustments * @param fs * @param dnapos */ private void sequencingErrorMenuItem(FeatureSetI fs, int dnapos) { if (fs.plus1FrameShiftPosition() != dnapos && fs.minus1FrameShiftPosition() != dnapos) { SequenceEdit seq_edit = fs.getSequencingErrorAtPosition(dnapos); if (seq_edit != null) { this.remove(sequencingErrorSubMenu); removeAdjustmentMenuItem.setText("Remove " + seq_edit.getEditType() + " here"); this.add(removeAdjustmentMenuItem); removeAdjustmentAction.setEnabled(true); } else { this.remove(removeAdjustmentMenuItem); this.add(sequencingErrorSubMenu); insertionAction.setEnabled(true); deletionAction.setEnabled(true); substitutionAction.setEnabled(true); } } else { this.remove(sequencingErrorSubMenu); this.remove(removeAdjustmentMenuItem); } } /** * Determines if a feature would be considered too small based on the * given start and end position. * * @param start_pos * @param end_pos * @return (end_pos - start_pos + 1) >= MIN_FEATURE_SIZE */ private boolean notTooSmall(int start_pos, int end_pos) { return (end_pos - start_pos + 1) >= MIN_FEATURE_SIZE; } /** * Gets the annotation editor * * @return */ private AnnotationEditor getEditor() { return curationState .getAnnotationEditor(panel.getStrand() == Strand.FORWARD); } /** * Determines whether or not the position has a sequencing error * @param dnapos * @return */ private boolean isSequencingErrorPosition(int dnapos) { return curationState.getCurationSet().getRefSequence() .isSequencingErrorPosition(dnapos); } } --- NEW FILE: BaseEditorPanel.java --- package apollo.gui.detailviewers.sequencealigner; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.DefaultTreeCellEditor.EditorContainer; import java.awt.*; import java.awt.event.*; import java.util.*; import apollo.datamodel.*; import apollo.seq.*; import apollo.seq.io.FastaFile; import apollo.util.*; import apollo.gui.SequenceSelector; import apollo.gui.event.*; import apollo.editor.AnnotationEditor; //import apollo.editor.ChangeList; import apollo.gui.ApolloFrame; import apollo.config.Config; [...1421 lines suppressed...] Object result = pane.getValue(); boolean okay = (result != null && opts[0].equals(result) ? true : false); return okay; } private CurationSet getCurationSet() { return curationState.getCurationSet(); } GuiCurationState getCurationState() { return curationState; } private class BaseEditorSelectionListener implements FeatureSelectionListener { public boolean handleFeatureSelectionEvent(FeatureSelectionEvent e) { if (!baseFineEditor.canHandleSelection(e,BaseEditorPanel.this)) return false; // canHandleSel ensures itsa AnnotatedFeatureI AnnotatedFeatureI g = (AnnotatedFeatureI)e.getFeatures().getFeature(0); displayAnnot(g); return true; } } } --- NEW FILE: BaseFineEditor.java --- package apollo.gui.detailviewers.sequencealigner; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Iterator; import java.util.Set; import java.util.Vector; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import apollo.dataadapter.DataLoadEvent; import apollo.dataadapter.DataLoadListener; import apollo.datamodel.AnnotatedFeatureI; import apollo.datamodel.CurationSet; import apollo.datamodel.FeatureSetI; import apollo.datamodel.SeqFeatureI; import apollo.datamodel.Transcript; import apollo.editor.AnnotationChangeEvent; import apollo.editor.AnnotationChangeListener; import apollo.gui.ControlledObjectI; import apollo.gui.Controller; import apollo.gui.Selection; import apollo.gui.SelectionManager; import apollo.gui.Transformer; import apollo.gui.event.BaseFocusEvent; import apollo.gui.event.FeatureSelectionEvent; import apollo.gui.event.FeatureSelectionListener; import apollo.gui.genomemap.StrandedZoomableApolloPanel; import apollo.gui.synteny.CurationManager; import apollo.gui.synteny.GuiCurationState; public class BaseFineEditor extends JFrame implements FeatureSelectionListener, ControlledObjectI, AnnotationChangeListener { private static final Color [] colorList = { new Color(0,0,0), new Color(255,255,0), new Color(0,255,255), new Color(255,0,255), new Color(255,0,0), new Color(0,255,0), new Color(0,0,255)}; private static int colorIndex = 0; /** RAY: The static list of all active EDEs */ private static ArrayList baseEditorInstanceList = new ArrayList(5); /** RAY: This is where the annotations get added */ protected BaseEditorPanel editorPanel = null; protected BaseEditorPanel resultPanel = null; /** RAY: The box at the bottom of the EDE which shows the selected transcript */ private TranslationViewer translationViewer; /** RAY: This is the box that holds the Scrollable part of the EDE */ private JViewport viewport; protected JLabel lengthLabel; /** RAY: The drop down menu with the list of transcripts in it */ private JComboBox transcriptComboBox; StrandedZoomableApolloPanel szap; Transformer transformer; private FineEditorScrollListener scrollListener; Color indicatorColor; JPanel colorSwatch; SelectionManager selection_manager; protected JButton findButton; protected JButton clearFindsButton; protected JButton goToButton; protected JCheckBox showIntronBox; // Need? private JCheckBox followSelectionCheckBox; protected JButton upstream_button; protected JButton downstream_button; private AnnotatedFeatureI currentAnnot;//Transcript protected Transcript neighbor_up; protected Transcript neighbor_down; private GuiCurationState curationState; public static void test( GuiCurationState curationState, int strand, Selection selection, String type) { JFrame frame = new JFrame("TopLevelDemo"); MultiSequenceAlignerFrame msa = MultiSequenceAlignerFrame.makeAligner(curationState, strand, selection, type); msa.setPreferredSize(new Dimension(1000, 800)); msa.pack(); msa.setVisible(true); AnnotatedFeatureI gai = getFirstAnnot(selection); if (gai != null) { msa.getPanel().scrollToBase(gai.getStart()); msa.getPanel().setSelection(gai); } } /** Returns first AnnotatedFeatureI in Selection on strand clicked on, null if there is none. Exon, Transcript, and Gene are all AnnotatedFeatureI's */ public static AnnotatedFeatureI getFirstAnnot(Selection selection) { for (int i=0; i < selection.size() ;i++) { SeqFeatureI feat = selection.getSelectedData(i); if (feat instanceof AnnotatedFeatureI ) { // If this is an exon, get the parent transcript // XXX: uncoment if you want to start at the beginning of the transcript //if (feat instanceof Exon) //feat = feat.getRefFeature(); return (AnnotatedFeatureI)feat; } } return null; } public static void showBaseEditor(AnnotatedFeatureI editMe,GuiCurationState curationState, SeqFeatureI geneHolder) { BaseFineEditor bfe = new BaseFineEditor(editMe,curationState,geneHolder); baseEditorInstanceList.add(bfe); } public static void showBaseEditor(AnnotatedFeatureI editMe,GuiCurationState curationState, SeqFeatureI geneHolder, Set<SeqFeatureI> selectedResults) { BaseFineEditor bfe = new BaseFineEditor(editMe,curationState,geneHolder, selectedResults); //bfe.addResults(selectedResults); ArrayList v = baseEditorInstanceList; baseEditorInstanceList.add(bfe); } private void addResults(Set<SeqFeatureI> results) { editorPanel.addResults(results); } private BaseFineEditor(AnnotatedFeatureI editMe,GuiCurationState curationState, SeqFeatureI geneHolder) { super((editMe.isForwardStrand() ? "Forward" : "Reverse") + " Strand Exon Editor"); this.curationState = curationState; curationState.getController().addListener(this); curationState.getController().addListener(new BaseEditorDataListener()); szap = curationState.getSZAP(); transformer = szap.getScaleView().getTransform(); int seqStart = curationState.getCurationSet().getLow(); int seqEnd = curationState.getCurationSet().getHigh(); //FeatureSetI annFeatSet=((DrawableFeatureSet)view.getDrawableSet()).getFeatureSet(); editorPanel = new BaseEditorPanel(curationState, this, !editMe.isForwardStrand(), seqStart, seqEnd, geneHolder); initGui(editMe); // cant do til after editorPanel made // cant do this til after initGui (editorPanel needs to know size) editorPanel.displayAnnot(editMe); attachListeners(); showEditRegion(); displayAnnot(getTransOrOneLevelAnn(editMe)); translationViewer.repaint(); setVisible(true); // Might just be linux, but bofe gets iconified on close if (getState()==Frame.ICONIFIED) setState(Frame.NORMAL); } private BaseFineEditor(AnnotatedFeatureI editMe,GuiCurationState curationState, SeqFeatureI geneHolder, Set<SeqFeatureI> selectedResults) { super((editMe.isForwardStrand() ? "Forward" : "Reverse") + " Strand Exon Editor"); this.curationState = curationState; curationState.getController().addListener(this); curationState.getController().addListener(new BaseEditorDataListener()); szap = curationState.getSZAP(); transformer = szap.getScaleView().getTransform(); int seqStart = curationState.getCurationSet().getLow(); int seqEnd = curationState.getCurationSet().getHigh(); CurationSet s = curationState.getCurationSet(); //FeatureSetI annFeatSet=((DrawableFeatureSet)view.getDrawableSet()).getFeatureSet(); // REFACTOR BaseEditorPanel - (what allows for selection and modification of the annotations?) // create BaseViewPanel -> have BaseEditorPanel extend it // take ... [truncated message content] |
From: elee <gk...@us...> - 2009-06-02 02:19:36
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/genomemap In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15048/apollo/gui/genomemap Modified Files: StrandedZoomableApolloPanel.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch Index: StrandedZoomableApolloPanel.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/gui/genomemap/StrandedZoomableApolloPanel.java,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** StrandedZoomableApolloPanel.java 8 Aug 2008 01:04:50 -0000 1.106 --- StrandedZoomableApolloPanel.java 2 Jun 2009 01:31:57 -0000 1.107 *************** *** 1469,1472 **** --- 1469,1474 ---- widthPixel = -widthPixel; } else if (hw.reverse) { + // RC: want to move start to the right when it is reversed + startXPixel = transformer.maxXPixelAtUserCoord(startCoord); startXPixel -= widthPixel; } *************** *** 1539,1542 **** --- 1541,1553 ---- highlightRegions.removeElement(new HighlightWrapper(scroller,null, false)); } + + public void updateHighlightRegion(BaseScrollable scroller, Color color, boolean reverse) { + int index = highlightRegions.indexOf(new HighlightWrapper(scroller,null, false)); + if (index >= 0) { + HighlightWrapper hw = (HighlightWrapper)highlightRegions.get(index); + hw.setColor(color); + hw.setReverse(reverse); + } + } public boolean isReverseComplement() { *************** *** 2237,2240 **** --- 2248,2267 ---- return highlightRect; } + + public boolean getReverse() { + return reverse; + } + + public void setReverse(boolean r){ + this.reverse = r; + } + + public Color getColor() { + return color; + } + + public void setColor(Color c) { + color = c; + } } /** Handles dragging of highlights. The drag only happens in scale view. |
From: elee <gk...@us...> - 2009-06-02 02:19:35
|
Update of /cvsroot/gmod/apollo/src/java/org/bdgp/util In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15048/org/bdgp/util Modified Files: DNAUtils.java RangeHash.java Added Files: RangeHolder.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch --- NEW FILE: RangeHolder.java --- package org.bdgp.util; public class RangeHolder implements Range { private int low; private int high; private int hashCache; public RangeHolder(int low, int high) { this.low = low; this.high = high; this.hashCache = new Integer(low).hashCode(); } public int getLow() { return low; } public int getHigh() { return high; } public boolean equals(Object o) { boolean result = false; if (o instanceof RangeHolder) { RangeHolder range = (RangeHolder) o; result = this.getLow() == range.getLow() && this.getHigh() == range.getHigh(); } return result; } public int hashCode() { return hashCache; } public String toString() { return "("+low+","+high+")"; } } Index: DNAUtils.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/org/bdgp/util/DNAUtils.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DNAUtils.java 1 Jun 2006 12:41:48 -0000 1.5 --- DNAUtils.java 2 Jun 2009 01:31:57 -0000 1.6 *************** *** 397,410 **** for (int i=0; i<buf.length(); i++) { base = buf.charAt(i); ! if (base == 'a') { buf.setCharAt(i, 't'); } ! else if (base == 'c') { buf.setCharAt(i, 'g'); } ! else if (base == 'g') { buf.setCharAt(i, 'c'); } ! else if (base == 't') { buf.setCharAt(i, 'a'); } ! else if (base == 'A') { buf.setCharAt(i, 'T'); } ! else if (base == 'C') { buf.setCharAt(i, 'G'); } ! else if (base == 'G') { buf.setCharAt(i, 'C'); } ! else if (base == 'T') { buf.setCharAt(i, 'A'); } } ! } /** --- 397,427 ---- for (int i=0; i<buf.length(); i++) { base = buf.charAt(i); ! buf.setCharAt(i, complement(base)); } ! } ! ! /** ! * determines the complement of a nucleotide ! * ! * @param base a character reperesenting a nucleotide ! * @return the character which represents the complement to the input base ! */ ! public static char complement(char base) { ! char complement = base; ! if (base == 'a') { complement = 't'; } ! else if (base == 'c') { complement = 'g'; } ! else if (base == 'g') { complement = 'c'; } ! else if (base == 't') { complement = 'a'; } ! else if (base == 'A') { complement = 'T'; } ! else if (base == 'C') { complement = 'G'; } ! else if (base == 'G') { complement = 'C'; } ! else if (base == 'T') { complement = 'A'; } ! ! if (complement == base) ! throw new IllegalArgumentException( ! "Could not find complement for '" + base + "'"); ! ! return complement; ! } /** *************** *** 576,583 **** // amino_acids.append("") calls int extra_bases = (length-(int)Math.abs(frame)) % 3; if (pre_string == null && post_string == null) { ! for (int i = frame; i < length-2; i += 3) { residue = genetic_code[basenums[i]][basenums[i+1]][basenums[i+2]]; amino_acids.append(residue); } for (int i = 0; i < extra_bases; i++) { --- 593,602 ---- // amino_acids.append("") calls int extra_bases = (length-(int)Math.abs(frame)) % 3; + int k = 0; if (pre_string == null && post_string == null) { ! for (int i = frame; i < length-2; i += 3, k = i) { residue = genetic_code[basenums[i]][basenums[i+1]][basenums[i+2]]; amino_acids.append(residue); + } for (int i = 0; i < extra_bases; i++) { Index: RangeHash.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/org/bdgp/util/RangeHash.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RangeHash.java 12 Oct 2005 22:58:15 -0000 1.1 --- RangeHash.java 2 Jun 2009 01:31:57 -0000 1.2 *************** *** 10,41 **** private Comparator rangeComparator = new RangeComparator(); - private class RangeHolder implements Range { - protected int low; - protected int high; - private int hashCache; - - public RangeHolder(int low, int high) { - this.low = low; - this.high = high; - this.hashCache = new Integer(low).hashCode(); - } - - public int getLow() { - return low; - } - - public int getHigh() { - return high; - } - - public int hashCode() { - return hashCache; - } - - public String toString() { - return "("+low+","+high+")"; - } - } - protected static boolean equals(Range a, Range b) { return a.getLow() == b.getLow() && a.getHigh() == b.getHigh(); --- 10,13 ---- *************** *** 159,162 **** --- 131,135 ---- } + // TODO: wtf? public int getIntervalIndex(int low, int high, boolean exact) { int lowPos = VectorUtil.binarySearch(ranges, *************** *** 211,214 **** --- 184,188 ---- output[0] = Double.NEGATIVE_INFINITY; output[1] = Double.POSITIVE_INFINITY; + return output; } |
From: elee <gk...@us...> - 2009-06-02 02:19:33
|
Update of /cvsroot/gmod/apollo/src/java/apollo/config In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15048/apollo/config Modified Files: PropertyScheme.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch Index: PropertyScheme.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/config/PropertyScheme.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PropertyScheme.java 5 May 2008 21:39:26 -0000 1.22 --- PropertyScheme.java 2 Jun 2009 01:31:57 -0000 1.23 *************** *** 153,156 **** --- 153,164 ---- } + public Enumeration getTypes() { + return fpTypeToPropHash.keys(); + } + + public Enumeration getAnalNames() { + return fpAnalNameToPropHash.keys(); + } + private void regenerateFeaturePropCaches() { fpTypeToPropHash.clear(); |
From: elee <gk...@us...> - 2009-06-02 02:19:30
|
Update of /cvsroot/gmod/apollo/src/java/apollo/gui/menus In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15048/apollo/gui/menus Modified Files: AnnotationMenu.java Log Message: Merger of TAIR sequence aligner editor with main Apollo branch Index: AnnotationMenu.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/gui/menus/AnnotationMenu.java,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** AnnotationMenu.java 5 Mar 2009 09:25:53 -0000 1.159 --- AnnotationMenu.java 2 Jun 2009 01:31:57 -0000 1.160 *************** *** 1,35 **** package apollo.gui.menus; import apollo.editor.AnnotationEditor; import apollo.editor.UserName; import apollo.analysis.AnalysisGUI; import apollo.config.Config; import apollo.gui.*; import apollo.gui.genomemap.AnnotationView; - import apollo.gui.genomemap.FeatureView; - import apollo.gui.genomemap.FeatureTierManager; - import apollo.gui.genomemap.ApolloPanel; import apollo.gui.genomemap.ApolloPanelI; ! import apollo.gui.drawable.DrawableAnnotationConstants; ! import apollo.gui.drawable.DrawableSeqFeature; ! import apollo.gui.event.*; import apollo.gui.synteny.GuiCurationState; - import apollo.gui.annotinfo.FeatureEditorDialog; - import apollo.gui.detailviewers.exonviewer.BaseFineEditor; - import apollo.gui.detailviewers.seqexport.SeqExport; - import apollo.datamodel.*; - import apollo.datamodel.seq.GAMESequence; - import apollo.seq.io.FastaFile; import apollo.util.FeatureList; import apollo.util.HTMLUtil; - import apollo.config.DisplayPrefsI; - - import java.io.*; - import java.awt.*; - import java.awt.event.*; - import java.util.*; - import javax.swing.*; - - import org.apache.log4j.*; /** Note that this is actually the popup menu you get when you right-click after --- 1,50 ---- package apollo.gui.menus; + import java.awt.Point; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.util.HashSet; + import java.util.Set; + import java.util.Vector; + + import javax.swing.JMenuItem; + import javax.swing.JOptionPane; + import javax.swing.JPopupMenu; + + import org.apache.log4j.LogManager; + import org.apache.log4j.Logger; + + import apollo.config.Config; + import apollo.config.DisplayPrefsI; + import apollo.datamodel.AnnotatedFeatureI; + import apollo.datamodel.CurationSet; + import apollo.datamodel.Exon; + import apollo.datamodel.FeatureSetI; + import apollo.datamodel.SeqFeatureI; + import apollo.datamodel.SequenceI; + import apollo.datamodel.Transcript; + import apollo.datamodel.seq.GAMESequence; import apollo.editor.AnnotationEditor; import apollo.editor.UserName; + + import apollo.gui.ApolloFrame; + import apollo.gui.PreferenceWindow; + import apollo.gui.Selection; + import apollo.gui.annotinfo.FeatureEditorDialog; + import apollo.gui.detailviewers.exonviewer.BaseFineEditor; + import apollo.gui.detailviewers.sequencealigner.MultiSequenceAlignerFrame; + import apollo.gui.detailviewers.seqexport.SeqExport; + import apollo.gui.drawable.DrawableAnnotationConstants; + import apollo.analysis.AnalysisGUI; import apollo.config.Config; import apollo.gui.*; + import apollo.gui.genomemap.AnnotationView; import apollo.gui.genomemap.ApolloPanelI; ! import apollo.gui.genomemap.FeatureTierManager; import apollo.gui.synteny.GuiCurationState; import apollo.util.FeatureList; import apollo.util.HTMLUtil; /** Note that this is actually the popup menu you get when you right-click after *************** *** 55,58 **** --- 70,74 ---- JMenuItem annotInfo; JMenuItem baseedit; + JMenuItem sequenceAligner; JMenuItem sequence; JMenuItem mergeExons; *************** *** 152,155 **** --- 168,172 ---- annotInfo = new JMenuItem("Annotation info..."); baseedit = new JMenuItem("Exon detail editor..."); + sequenceAligner = new JMenuItem("Sequence Aligner..."); sequence = new JMenuItem("Sequence..."); delete = new JMenuItem("Delete selection"); *************** *** 232,236 **** --- 249,255 ---- if (Config.isEditingEnabled()) { add(baseedit); + add(sequenceAligner); baseedit.setEnabled (haveResidues && haveWholeSeq && haveAnnot); + sequenceAligner.setEnabled (haveResidues && haveWholeSeq && haveAnnot); } *************** *** 352,355 **** --- 371,375 ---- annotInfo .addActionListener(this); baseedit .addActionListener(this); + sequenceAligner .addActionListener(this); // disable on multiple transcripts? sequence.addActionListener(new ActionListener() { *************** *** 382,385 **** --- 402,406 ---- annotInfo .setMnemonic('E'); baseedit .setMnemonic('B'); + sequenceAligner.setMnemonic('A'); sequence.setMnemonic('T'); mergeTran.setMnemonic('M'); *************** *** 413,416 **** --- 434,438 ---- e.getSource() == annotInfo || e.getSource() == baseedit || + e.getSource() == sequenceAligner || e.getSource() == mergeExons || e.getSource() == mergeTran || *************** *** 438,441 **** --- 460,464 ---- if (warnOnEdit() && (e.getSource() == delete || e.getSource() == baseedit || + e.getSource() == sequenceAligner || e.getSource() == mergeExons || e.getSource() == mergeTran || *************** *** 474,477 **** --- 497,506 ---- BaseFineEditor.showBaseEditor(gai,curationState,annotView.getGeneHolder()); + + } else if (e.getSource() == sequenceAligner) { + + MultiSequenceAlignerFrame + .makeAligner(curationState, strand, selection, SequenceI.DNA); + } else if (e.getSource() == splitExon) { editor.splitExon(); |