boolean renderGaps = true;
boolean showSequenceFeatures = false;
boolean showAnnotation = true;
- boolean showConservation = true;
- boolean showQuality = true;
- boolean showIdentity = true;
boolean colourAppliesToAllGroups = true;
ColourSchemeI globalColourScheme = null;
boolean conservationColourSelected = false;
boolean gatherViewsHere = false;
+ Stack historyList = new Stack();
+ Stack redoList = new Stack();
+
+ Hashtable sequenceColours;
+
+ int thresholdTextColour = 0;
+ Color textColour = Color.black;
+ Color textColour2 = Color.white;
+
+ boolean rightAlignIds = false;
+
+ Hashtable hiddenRepSequences;
+
- public AlignViewport(AlignmentI al, boolean dataset)
- {
- isDataset = dataset;
- setAlignment(al);
- init();
- }
/**
* Creates a new AlignViewport object.
*
showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);
showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);
- showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
- showQuality = Cache.getDefault("SHOW_QUALITY", true);
- showIdentity = Cache.getDefault("SHOW_IDENTITY", true);
+ rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false);
autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
- padGaps = Cache.getDefault("PAD_GAPS", false);
+ padGaps = Cache.getDefault("PAD_GAPS", true);
String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ;
setFont(new Font(fontName, style, Integer.parseInt(fontSize)));
-
alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) );
AlignmentAnnotation.BAR_GRAPH);
conservation.hasText = true;
- if (showConservation)
+
+ if (Cache.getDefault("SHOW_CONSERVATION", true))
{
alignment.addAnnotation(conservation);
}
- if (showQuality)
+ if (Cache.getDefault("SHOW_QUALITY", true))
{
quality = new AlignmentAnnotation("Quality",
"Alignment Quality based on Blosum62 scores",
0f,
11f,
AlignmentAnnotation.BAR_GRAPH);
+ quality.hasText = true;
alignment.addAnnotation(quality);
}
AlignmentAnnotation.BAR_GRAPH);
consensus.hasText = true;
- if (showIdentity)
+ if (Cache.getDefault("SHOW_IDENTITY", true))
{
alignment.addAnnotation(consensus);
}
-
}
if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
globalColourScheme.setConsensus(hconsensus);
}
}
+
+ wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false);
}
{
try
{
- long t = System.currentTimeMillis();
+ updatingConservation = true;
+
+ while (UPDATING_CONSERVATION)
+ {
+ try
+ {
+ if (ap != null)
+ {
+ ap.repaint();
+ }
+ Thread.sleep(200);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ UPDATING_CONSERVATION = true;
+
+
+ int alWidth = alignment.getWidth();
+ if(alWidth<0)
+ return;
Conservation cons = new jalview.analysis.Conservation("All",
jalview.schemes.ResidueProperties.propHash, 3,
- alignment.getSequences(), 0, alignment.getWidth() - 1);
+ alignment.getSequences(), 0, alWidth -1);
cons.calculate();
cons.verdict(false, ConsPercGaps);
- if (showQuality)
+ if (quality!=null)
{
cons.findQuality();
}
- System.out.println("Conservation took " + (System.currentTimeMillis() - t) +
- "ms");
-
- int alWidth = alignment.getWidth();
- String sequence = cons.getConsSequence().getSequence();
+ char [] sequence = cons.getConsSequence().getSequence();
float minR;
float minG;
float minB;
conservation.annotations = new Annotation[alWidth];
- if (showQuality)
+ if (quality!=null)
{
+ quality.graphMax = cons.qualityRange[1].floatValue();
quality.annotations = new Annotation[alWidth];
qmin = cons.qualityRange[0].floatValue();
qmax = cons.qualityRange[1].floatValue();
{
float value = 0;
- c = sequence.charAt(i);
+ c = sequence[i];
if (Character.isDigit(c))
value = (int) (c - '0');
minB + (maxB * vprop)));
// Quality calc
- if (showQuality)
+ if (quality!=null)
{
value = ( (Double) cons.quality.get(i)).floatValue();
vprop = value - qmin;
minB + (maxB * vprop)));
}
}
-
- if (quality != null)
- {
- quality.graphMax = cons.qualityRange[1].floatValue();
- }
}
catch (OutOfMemoryError error)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+
+
public void run()
{
javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
}
});
+ conservation = null;
+ quality = null;
+
System.out.println("Conservation calculation: " + error);
System.gc();
}
+ UPDATING_CONSERVATION = false;
+ updatingConservation = false;
+
if(ap!=null)
{
ap.repaint();
}
- updatingConservation = false;
+
}
}
boolean consUpdateNeeded = false;
+ static boolean UPDATING_CONSENSUS = false;
+
+ static boolean UPDATING_CONSERVATION = false;
+
boolean updatingConsensus = false;
boolean updatingConservation = false;
/**
* DOCUMENT ME!
*/
- public void updateConservation(AlignmentPanel ap)
+ public void updateConservation(final AlignmentPanel ap)
{
- if (alignment.isNucleotide())
+ if (alignment.isNucleotide() || conservation==null)
return;
- updatingConservation = true;
-
- if (conservationThread == null || !conservationThread.isAlive())
- {
- conservationThread = new ConservationThread(ap);
- conservationThread.start();
- }
- else
- {
- consUpdateNeeded = true;
- System.out.println("come back later");
- }
+ conservationThread = new ConservationThread(ap);
+ conservationThread.start();
}
/**
* DOCUMENT ME!
*/
- public void updateConsensus(AlignmentPanel ap)
+ public void updateConsensus(final AlignmentPanel ap)
{
- updatingConsensus = true;
-
- if (consensusThread == null || !consensusThread.isAlive())
- {
- consensusThread = new ConsensusThread(ap);
- consensusThread.start();
- }
- else
- {
- consUpdateNeeded = true;
- System.out.println("come back later");
- }
+ consensusThread = new ConsensusThread(ap);
+ consensusThread.start();
}
}
public void run()
{
+ updatingConsensus = true;
+ while (UPDATING_CONSENSUS)
+ {
+ try
+ {
+ if (ap != null)
+ {
+ ap.repaint();
+ }
+
+ Thread.sleep(200);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+
+ UPDATING_CONSENSUS = true;
+
try
{
int aWidth = alignment.getWidth();
+ if(aWidth<0)
+ return;
consensus.annotations = null;
consensus.annotations = new Annotation[aWidth];
- long t = System.currentTimeMillis();
+
hconsensus = new Hashtable[aWidth];
AAFrequency.calculate(alignment.getSequencesArray(),
0,
alignment.getWidth(),
hconsensus);
- System.out.println("Consensus took " +
- (System.currentTimeMillis() - t) + "ms");
-
for (int i = 0; i < aWidth; i++)
{
float value = 0;
}
catch (OutOfMemoryError error)
{
+ alignment.deleteAnnotation(consensus);
+
+ consensus = null;
+ hconsensus = null;
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
System.out.println("Consensus calculation: " + error);
System.gc();
}
+ UPDATING_CONSENSUS = false;
+ updatingConsensus = false;
if (ap != null)
{
ap.repaint();
}
-
-
- updatingConsensus = false;
}
}
/**
seqs.append(consensus.annotations[i].displayCharacter);
}
}
+
SequenceI sq = new Sequence("Consensus", seqs.toString());
sq.setDescription("Percentage Identity Consensus "+((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
return sq;
hasHiddenColumns = true;
}
+ public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
+ {
+ int sSize = sg.getSize();
+ if(sSize < 2)
+ return;
+
+ if(hiddenRepSequences==null)
+ hiddenRepSequences = new Hashtable();
+
+ hiddenRepSequences.put(repSequence, sg);
+
+ //Hide all sequences except the repSequence
+ SequenceI [] seqs = new SequenceI[sSize-1];
+ int index = 0;
+ for(int i=0; i<sSize; i++)
+ if(sg.getSequenceAt(i)!=repSequence)
+ {
+ if(index==sSize-1)
+ return;
+
+ seqs[index++] = sg.getSequenceAt(i);
+ }
+
+ hideSequence(seqs);
+
+ }
+
public void hideAllSelectedSeqs()
{
if (selectionGroup == null)
if(seq!=null)
{
for (int i = 0; i < seq.length; i++)
+ {
alignment.getHiddenSequences().hideSequence(seq[i]);
-
+ }
hasHiddenRows = true;
firePropertyChange("alignment", null, alignment.getSequences());
}
public void showSequence(int index)
{
- Vector tmp = alignment.getHiddenSequences().showSequence(index);
+ Vector tmp = alignment.getHiddenSequences().showSequence(index
+ , hiddenRepSequences);
if(tmp.size()>0)
{
if(selectionGroup==null)
selectionGroup = new SequenceGroup();
selectionGroup.setEndRes(alignment.getWidth()-1);
}
- Vector tmp = alignment.getHiddenSequences().showAll();
+ Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences);
for(int t=0; t<tmp.size(); t++)
{
selectionGroup.addSequence(
}
firePropertyChange("alignment", null, alignment.getSequences());
hasHiddenRows = false;
+ hiddenRepSequences = null;
}
}
+
+
public void invertColumnSelection()
{
- int column;
for(int i=0; i<alignment.getWidth(); i++)
{
- column = i;
-
- if(colSel.contains(column))
- colSel.removeElement(column);
+ if(colSel.contains(i))
+ colSel.removeElement(i);
else
- colSel.addElement(column);
-
+ {
+ if (!hasHiddenColumns || colSel.isVisible(i))
+ {
+ colSel.addElement(i);
+ }
+ }
}
-
}
public int adjustForHiddenSeqs(int alignmentIndex)
int start = 0, end = 0;
if(selectedRegionOnly && selectionGroup!=null)
{
- iSize = selectionGroup.getSize(false);
+ iSize = selectionGroup.getSize();
seqs = selectionGroup.getSequencesInOrder(alignment);
start = selectionGroup.getStartRes();
end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
int start = 0, end = 0;
if(selectedRegionOnly && selectionGroup!=null)
{
- iSize = selectionGroup.getSize(false);
+ iSize = selectionGroup.getSize();
seqs = selectionGroup.getSequencesInOrder(alignment);
start = selectionGroup.getStartRes();
end = selectionGroup.getEndRes()+1;
} else {
for(i=0; i<iSize; i++)
{
- selection[i] = seqs[i].getSequence(start, end);
+ selection[i] = seqs[i].getSequenceAsString(start, end);
}
}
return sequenceSetID;
}
+ public void alignmentChanged(AlignmentPanel ap)
+ {
+ if (padGaps)
+ alignment.padGaps();
+
+ if (hconsensus != null && autoCalculateConsensus)
+ {
+ updateConsensus(ap);
+ updateConservation(ap);
+ }
+
+ //Reset endRes of groups if beyond alignment width
+ int alWidth = alignment.getWidth();
+ Vector groups = alignment.getGroups();
+ if(groups!=null)
+ {
+ for(int i=0; i<groups.size(); i++)
+ {
+ SequenceGroup sg = (SequenceGroup)groups.elementAt(i);
+ if(sg.getEndRes()>alWidth)
+ sg.setEndRes(alWidth-1);
+ }
+ }
+
+ if(selectionGroup!=null && selectionGroup.getEndRes()>alWidth)
+ selectionGroup.setEndRes(alWidth-1);
+
+ resetAllColourSchemes();
+
+ alignment.adjustSequenceAnnotations();
+ }
+
+
+ void resetAllColourSchemes()
+ {
+ ColourSchemeI cs = globalColourScheme;
+ if(cs!=null)
+ {
+ if (cs instanceof ClustalxColourScheme)
+ {
+ ( (ClustalxColourScheme) cs).
+ resetClustalX(alignment.getSequences(),
+ alignment.getWidth());
+ }
+
+ cs.setConsensus(hconsensus);
+ if (cs.conservationApplied())
+ {
+ Alignment al = (Alignment) alignment;
+ Conservation c = new Conservation("All",
+ ResidueProperties.propHash, 3,
+ al.getSequences(), 0,
+ al.getWidth() - 1);
+ c.calculate();
+ c.verdict(false, ConsPercGaps);
+
+ cs.setConservation(c);
+ }
+ }
+
+ int s, sSize = alignment.getGroups().size();
+ for(s=0; s<sSize; s++)
+ {
+ SequenceGroup sg = (SequenceGroup)alignment.getGroups().elementAt(s);
+ if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
+ {
+ ((ClustalxColourScheme)sg.cs).resetClustalX(
+ sg.getSequences(hiddenRepSequences), sg.getWidth());
+ }
+ sg.recalcConservation();
+ }
+ }
+
+
+ public Color getSequenceColour(SequenceI seq)
+ {
+ if(sequenceColours==null || !sequenceColours.containsKey(seq))
+ return Color.white;
+ else
+ return (Color)sequenceColours.get(seq);
+ }
+
+ public void setSequenceColour(SequenceI seq, Color col)
+ {
+ if(sequenceColours==null)
+ sequenceColours = new Hashtable();
+
+ if(col == null)
+ sequenceColours.remove(seq);
+ else
+ sequenceColours.put(seq, col);
+ }
+
+
}