<classpathentry kind="lib" path="lib/jdas-1.0.4.jar"/>
<classpathentry kind="lib" path="lib/spring-core-3.0.5.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/spring-web-3.0.5.RELEASE.jar"/>
- <classpathentry kind="lib" path="lib/groovy-all-1.8.2.jar"/>
<classpathentry kind="lib" path="lib/min-jabaws-client-2.1.0.jar" sourcepath="/clustengine"/>
<classpathentry kind="lib" path="lib/json_simple-1.1.jar" sourcepath="/Users/jimp/Downloads/json_simple-1.1-all.zip"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.7.jar"/>
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
<classpathentry kind="lib" path="lib/biojava-core-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/biojava-ontology-4.1.0.jar"/>
+ <classpathentry kind="lib" path="lib/groovy-all-2.4.6-indy.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<p>Here are some scripts to get you started:</p>
<ul><li>Getting the title, alignment and first sequence from the current alignFrame<br>
<pre>
-def alf = Jalview.getAlignframes();
+def alf = Jalview.getAlignFrames();
print alf[0].getTitle();
def alignment = alf[0].viewport.alignment;
def seq = alignment.getSequenceAt(0);
ST-TURN-IIL blue|255,0,255|absolute|20.0|95.0|below|66.0
-GAMMA-TURN-CLASSIC red|0,255,255|20.0|95.0|below|66.0
+GAMMA-TURN-CLASSIC red|0,255,255|20.0|95.0|below|66.0
BETA-TURN-IR 9a6a94
BETA-TURN-IL d6a6ca
BETA-BULGE 1dc451
* Example script that registers two alignment annotation calculators
* - one that counts residues in a column with Pfam annotation
* - one that counts only charged residues with Pfam annotation
+ * To try this, first load uniref50.fa from the examples folder, then load features
+ * from examples/exampleFeatures.txt, before running this script from the Groovy console.
+
* Modify this example as required to count by column any desired value that can be
* derived from the residue and sequence features at each position of an alignment.
*/
* - a closure (groovy function) that tests whether to include a residue
* - a closure that tests whether to increment count based on sequence features
*/
-def getColumnCounter = { name, desc, residueTester, featureCounter ->
+def getColumnCounter = { name, desc, acceptResidue, acceptFeatures ->
[
getName: { name },
getDescription: { desc },
count:
{ res, feats ->
def c = 0
- if (residueTester.call(res))
+ if (acceptResidue.call(res))
{
- if (featureCounter.call(feats))
+ if (acceptFeatures.call(feats))
{
c++
}
}
/*
- * Define annotation that counts any residue with Pfam domain annotation
+ * Define an annotation that counts any residue with Pfam domain annotation
*/
def pfamAnnotation = getColumnCounter("Pfam", "Count of residues with Pfam domain annotation", {true}, hasPfam)
/*
- * Define annotation that counts charged residues with Pfam domain annotation
+ * Define an annotation that counts charged residues with Pfam domain annotation
*/
def chargedPfamAnnotation = getColumnCounter("Pfam charged", "Count of charged residues with Pfam domain annotation", isCharged, hasPfam)
label.blasting_for_unidentified_sequence = BLASTing for unidentified sequences
label.select_columns_containing = Select columns containing
label.select_columns_not_containing = Select columns that do not contain
+label.hide_columns_containing = Hide columns containing
+label.hide_columns_not_containing = Hide columns that do not contain
option.trim_retrieved_seqs = Trim retrieved sequences
label.trim_retrieved_sequences = When the reference sequence is longer than the sequence that you are working with, only keep the relevant subsequences.
label.use_sequence_id_1 = Use $SEQUENCE_ID$ or $SEQUENCE_ID=/<regex>/=$
start.setText(features[0].getBegin() + "");
end.setText(features[0].getEnd() + "");
description.setText(features[0].getDescription());
- Color col = getColour(name.getText());
- if (col == null)
- {
- col = new jalview.schemes.UserColourScheme()
- .createColourFromName(name.getText());
- }
Object fcol = getFeatureStyle(name.getText());
// simply display the feature color in a box
colourPanel.updateColor(fcol);
});
men.add(dens);
+
if (minmax != null)
{
final float[][] typeMinMax = minmax.get(type);
});
}
}
+
+ MenuItem selectContaining = new MenuItem(
+ MessageManager.getString("label.select_columns_containing"));
+ selectContaining.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ me.ap.alignFrame.avc.markColumnsContainingFeatures(false, false,
+ false, type);
+ }
+ });
+ men.add(selectContaining);
+
+ MenuItem selectNotContaining = new MenuItem(
+ MessageManager.getString("label.select_columns_not_containing"));
+ selectNotContaining.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ me.ap.alignFrame.avc.markColumnsContainingFeatures(true, false,
+ false, type);
+ }
+ });
+ men.add(selectNotContaining);
+
+ MenuItem hideContaining = new MenuItem(
+ MessageManager.getString("label.hide_columns_containing"));
+ hideContaining.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ hideFeatureColumns(type, true);
+ }
+ });
+ men.add(hideContaining);
+
+ MenuItem hideNotContaining = new MenuItem(
+ MessageManager.getString("label.hide_columns_not_containing"));
+ hideNotContaining.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ hideFeatureColumns(type, false);
+ }
+ });
+ men.add(hideNotContaining);
+
this.featurePanel.add(men);
men.show(this.featurePanel, x, y);
}
{
}
+ /**
+ * Hide columns containing (or not containing) a given feature type
+ *
+ * @param type
+ * @param columnsContaining
+ */
+ void hideFeatureColumns(final String type,
+ boolean columnsContaining)
+ {
+ if (ap.alignFrame.avc.markColumnsContainingFeatures(
+ columnsContaining, false, false, type))
+ {
+ if (ap.alignFrame.avc.markColumnsContainingFeatures(
+ !columnsContaining, false, false, type))
+ {
+ ap.alignFrame.viewport.hideSelectedColumns();
+ }
+ }
+ }
+
}
*/
public static void main(String[] args)
{
+ System.setSecurityManager(null);
System.out.println("Java version: "
+ System.getProperty("java.version"));
System.out.println(System.getProperty("os.arch") + " "
* Return absolute column index for a visible column index
*
* @param column
- * int column index in alignment view
+ * int column index in alignment view (count from zero)
* @return alignment column index for column
*/
public int adjustForHiddenColumns(int column)
import jalview.io.JalviewFileChooser;
import jalview.schemes.AnnotationColourGradient;
import jalview.schemes.GraduatedColor;
+import jalview.util.Format;
import jalview.util.MessageManager;
+import jalview.util.QuickSort;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.dbsources.das.api.jalviewSourceI;
MessageManager.getString("label.select_columns_containing"));
selCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
MessageManager.getString("label.select_columns_not_containing"));
clearCols.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent arg0)
{
false, type);
}
});
+ JMenuItem hideCols = new JMenuItem(
+ MessageManager.getString("label.hide_columns_containing"));
+ hideCols.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent arg0)
+ {
+ fr.ap.alignFrame.hideFeatureColumns(type, true);
+ }
+ });
+ JMenuItem hideOtherCols = new JMenuItem(
+ MessageManager.getString("label.hide_columns_not_containing"));
+ hideOtherCols.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent arg0)
+ {
+ fr.ap.alignFrame.hideFeatureColumns(type, false);
+ }
+ });
men.add(selCols);
men.add(clearCols);
+ men.add(hideCols);
+ men.add(hideOtherCols);
men.show(table, x, y);
}
void save()
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
+ Cache.getProperty("LAST_DIRECTORY"),
new String[] { "fc" },
new String[] { "Sequence Feature Colours" },
"Sequence Feature Colours");
PrintWriter out = new PrintWriter(new OutputStreamWriter(
new FileOutputStream(choice), "UTF-8"));
- Set fr_colours = fr.getAllFeatureColours();
- Iterator e = fr_colours.iterator();
+ Set<String> fr_colours = fr.getAllFeatureColours();
+ Iterator<String> e = fr_colours.iterator();
float[] sortOrder = new float[fr_colours.size()];
String[] sortTypes = new String[fr_colours.size()];
int i = 0;
while (e.hasNext())
{
- sortTypes[i] = e.next().toString();
+ sortTypes[i] = e.next();
sortOrder[i] = fr.getOrder(sortTypes[i]);
i++;
}
- jalview.util.QuickSort.sort(sortOrder, sortTypes);
+ QuickSort.sort(sortOrder, sortTypes);
sortOrder = null;
Object fcol;
GraduatedColor gcol;
- for (i = 0; i < sortTypes.length; i++)
+ for (String featureType : sortTypes)
{
jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
- col.setName(sortTypes[i]);
- col.setRGB(jalview.util.Format.getHexString(fr.getColour(col
- .getName())));
- fcol = fr.getFeatureStyle(sortTypes[i]);
+ col.setName(featureType);
+ fcol = fr.getFeatureStyle(featureType);
+ Color colour = fcol instanceof Color ? (Color) fcol
+ : ((GraduatedColor) fcol).getMaxColor();
+ col.setRGB(Format.getHexString(colour));
if (fcol instanceof GraduatedColor)
{
gcol = (GraduatedColor) fcol;
col.setMin(gcol.getMin());
col.setMax(gcol.getMax());
- col.setMinRGB(jalview.util.Format.getHexString(gcol
+ col.setMinRGB(Format.getHexString(gcol
.getMinColor()));
col.setAutoScale(gcol.isAutoScale());
col.setThreshold(gcol.getThresh());
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
+import java.awt.Color;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.DataInputStream;
.getFeatureRenderer().getRenderOrder()
.toArray(new String[0]);
- Vector settingsAdded = new Vector();
+ Vector<String> settingsAdded = new Vector<String>();
Object gstyle = null;
GraduatedColor gcol = null;
if (renderOrder != null)
{
- for (int ro = 0; ro < renderOrder.length; ro++)
+ for (String featureType : renderOrder)
{
gstyle = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getFeatureStyle(renderOrder[ro]);
+ .getFeatureStyle(featureType);
Setting setting = new Setting();
- setting.setType(renderOrder[ro]);
+ setting.setType(featureType);
if (gstyle instanceof GraduatedColor)
{
gcol = (GraduatedColor) gstyle;
}
else
{
- setting.setColour(ap.getSeqPanel().seqCanvas
- .getFeatureRenderer().getColour(renderOrder[ro])
- .getRGB());
+ setting.setColour(((Color) gstyle).getRGB());
}
setting.setDisplay(av.getFeaturesDisplayed().isVisible(
- renderOrder[ro]));
+ featureType));
float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getOrder(renderOrder[ro]);
+ .getOrder(featureType);
if (rorder > -1)
{
setting.setOrder(rorder);
}
fs.addSetting(setting);
- settingsAdded.addElement(renderOrder[ro]);
+ settingsAdded.addElement(featureType);
}
}
- // Make sure we save none displayed feature settings
- Iterator en = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getFeatureColours().keySet().iterator();
- while (en.hasNext())
- {
- String key = en.next().toString();
- if (settingsAdded.contains(key))
- {
- continue;
- }
-
- Setting setting = new Setting();
- setting.setType(key);
- setting.setColour(ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getColour(key).getRGB());
-
- setting.setDisplay(false);
- float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getOrder(key);
- if (rorder > -1)
- {
- setting.setOrder(rorder);
- }
- fs.addSetting(setting);
- settingsAdded.addElement(key);
- }
// is groups actually supposed to be a map here ?
- en = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ Iterator<String> en = ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer()
.getFeatureGroups().iterator();
- Vector groupsAdded = new Vector();
+ Vector<String> groupsAdded = new Vector<String>();
while (en.hasNext())
{
- String grp = en.next().toString();
+ String grp = en.next();
if (groupsAdded.contains(grp))
{
continue;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
ColumnSelection cs = av.getColumnSelection();
int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight();
- int s;
if (cs != null)
{
gg.setColor(new Color(220, 0, 0));
}
}
}
- // Draw the scale numbers
- gg.setColor(Color.black);
-
- int scalestartx = (startx / 10) * 10;
-
- SequenceI refSeq = av.getAlignment().getSeqrep();
- int refSp = 0, refEp = -1, refStart = 0, refEnd = -1, refStartI = 0, refEndI = -1;
- if (refSeq != null)
- {
- // find bounds and set origin appopriately
- // locate first visible position for this sequence
- int[] refbounds = av.getColumnSelection()
- .locateVisibleBoundsOfSequence(refSeq);
-
- refSp = refbounds[0];
- refEp = refbounds[1];
- refStart = refbounds[2];
- refEnd = refbounds[3];
- refStartI = refbounds[4];
- refEndI = refbounds[5];
- scalestartx = refSp + ((scalestartx - refSp) / 10) * 10;
- }
-
int widthx = 1 + endx - startx;
FontMetrics fm = gg.getFontMetrics(av.getFont());
- int y = avCharHeight - fm.getDescent();
-
- if (refSeq == null && scalestartx % 10 == 0)
- {
- scalestartx += 5;
- }
-
- String string;
- int maxX = 0, refN, iadj;
- // todo: add a 'reference origin column' to set column number relative to
- for (int i = scalestartx; i < endx; i += 5)
- {
- if (((i - refSp) % 10) == 0)
- {
- iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1;
- if (refSeq == null)
- {
- string = String.valueOf(iadj + 1);
- }
- else
- {
- refN = refSeq.findPosition(iadj);
- // TODO show bounds if position is a gap
- // - ie L--R -> "1L|2R" for
- // marker
- if (iadj < refStartI)
- {
- string = String.valueOf(iadj - refStartI);
- }
- else if (iadj > refEndI)
- {
- string = "+" + String.valueOf(iadj - refEndI);
- }
- else
- {
- string = String.valueOf(refN) + refSeq.getCharAt(iadj);
- }
- }
- if ((i - startx - 1) * avCharWidth > maxX)
- {
- gg.drawString(string, (i - startx - 1) * avCharWidth, y);
- maxX = (i - startx + 1) * avCharWidth + fm.stringWidth(string);
- }
-
- gg.drawLine(((i - startx - 1) * avCharWidth) + (avCharWidth / 2),
- y + 2,
- ((i - startx - 1) * avCharWidth) + (avCharWidth / 2), y
- + (fm.getDescent() * 2));
- }
- else
- {
- gg.drawLine(((i - startx - 1) * avCharWidth) + (avCharWidth / 2), y
- + fm.getDescent(), ((i - startx - 1) * avCharWidth)
- + (avCharWidth / 2), y + (fm.getDescent() * 2));
- }
- }
-
+ int y = avCharHeight, yOf = fm.getDescent();
+ y -= yOf;
if (av.hasHiddenColumns())
{
+ // draw any hidden column markers
gg.setColor(Color.blue);
int res;
if (av.getShowHiddenMarkers()
continue;
}
- gg.fillPolygon(new int[] { res * avCharWidth - avCharHeight / 4,
- res * avCharWidth + avCharHeight / 4, res * avCharWidth },
- new int[] { y - avCharHeight / 2, y - avCharHeight / 2,
- y + 8 }, 3);
+ gg.fillPolygon(new int[] {
+ -1 + res * avCharWidth - avCharHeight / 4,
+ -1 + res * avCharWidth + avCharHeight / 4,
+ -1 + res * avCharWidth }, new int[] { y, y, y + 2 * yOf }, 3);
}
}
+ }
+ // Draw the scale numbers
+ gg.setColor(Color.black);
+
+ int maxX = 0;
+ List<Object[]> marks = jalview.renderer.ScaleRenderer.calculateMarks(
+ av, startx, endx);
+ for (Object[] mark : marks)
+ {
+ boolean major = Boolean.valueOf((Boolean) mark[0]);
+ int mpos = ((Integer) mark[1]).intValue(); // (i - startx - 1)
+ String mstring = (String) mark[2];
+ if (mstring != null)
+ {
+ if (mpos * avCharWidth > maxX)
+ {
+ gg.drawString(mstring, mpos * avCharWidth, y);
+ maxX = (mpos + 2) * avCharWidth + fm.stringWidth(mstring);
+ }
+ }
+ if (major)
+ {
+ gg.drawLine((mpos * avCharWidth) + (avCharWidth / 2), y + 2,
+ (mpos * avCharWidth) + (avCharWidth / 2), y + (yOf * 2));
+ }
+ else
+ {
+ gg.drawLine((mpos * avCharWidth) + (avCharWidth / 2), y + yOf,
+ (mpos * avCharWidth) + (avCharWidth / 2), y + (yOf * 2));
+ }
+ }
+ if (av.hasHiddenColumns())
+ {
if (reveal != null && reveal[0] > startx && reveal[0] < endx)
{
gg.drawString(MessageManager.getString("label.reveal_columns"),
}
}
+
}
private void drawNorthScale(Graphics g, int startx, int endx, int ypos)
{
updateViewport();
- int scalestartx = startx - (startx % 10) + 10;
-
- g.setColor(Color.black);
- // NORTH SCALE
- for (int i = scalestartx; i < endx; i += 10)
+ for (Object[] mark : jalview.renderer.ScaleRenderer.calculateMarks(av,
+ startx, endx))
{
- int value = i;
- if (av.hasHiddenColumns())
+ int mpos = ((Integer) mark[1]).intValue(); // (i - startx - 1)
+ if (mpos < 0)
{
- value = av.getColumnSelection().adjustForHiddenColumns(value);
+ continue;
}
+ String mstring = (String) mark[2];
- g.drawString(String.valueOf(value), (i - startx - 1) * charWidth,
- ypos - (charHeight / 2));
-
- g.drawLine(((i - startx - 1) * charWidth) + (charWidth / 2),
- (ypos + 2) - (charHeight / 2), ((i - startx - 1) * charWidth)
- + (charWidth / 2), ypos - 2);
+ if (Boolean.valueOf((Boolean) mark[0]))
+ {
+ if (mstring != null)
+ {
+ g.drawString(mstring, mpos * charWidth, ypos - (charHeight / 2));
+ }
+ g.drawLine((mpos * charWidth) + (charWidth / 2), (ypos + 2)
+ - (charHeight / 2), (mpos * charWidth) + (charWidth / 2),
+ ypos - 2);
+ }
}
}
features = sequences[i].getSequenceFeatures();
if (features != null)
{
- for (int j = 0; j < features.length; j++)
+ for (SequenceFeature sequenceFeature : features)
{
- isnonpos = features[j].begin == 0 && features[j].end == 0;
+ isnonpos = sequenceFeature.begin == 0 && sequenceFeature.end == 0;
if ((!nonpos && isnonpos)
|| (!isnonpos && visOnly && !visible
- .containsKey(features[j].type)))
+ .containsKey(sequenceFeature.type)))
{
// skip if feature is nonpos and we ignore them or if we only
// output visible and it isn't non-pos and it's not visible
}
if (group != null
- && (features[j].featureGroup == null || !features[j].featureGroup
+ && (sequenceFeature.featureGroup == null || !sequenceFeature.featureGroup
.equals(group)))
{
continue;
}
- if (group == null && features[j].featureGroup != null)
+ if (group == null && sequenceFeature.featureGroup != null)
{
continue;
}
// we have features to output
featuresGen = true;
- if (features[j].description == null
- || features[j].description.equals(""))
+ if (sequenceFeature.description == null
+ || sequenceFeature.description.equals(""))
{
- out.append(features[j].type).append(TAB);
+ out.append(sequenceFeature.type).append(TAB);
}
else
{
- if (features[j].links != null
- && features[j].getDescription().indexOf("<html>") == -1)
+ if (sequenceFeature.links != null
+ && sequenceFeature.getDescription().indexOf("<html>") == -1)
{
out.append("<html>");
}
- out.append(features[j].description + " ");
- if (features[j].links != null)
+ out.append(sequenceFeature.description);
+ if (sequenceFeature.links != null)
{
- for (int l = 0; l < features[j].links.size(); l++)
+ for (int l = 0; l < sequenceFeature.links.size(); l++)
{
- String label = features[j].links.elementAt(l).toString();
+ String label = sequenceFeature.links.elementAt(l);
String href = label.substring(label.indexOf("|") + 1);
label = label.substring(0, label.indexOf("|"));
- if (features[j].description.indexOf(href) == -1)
+ if (sequenceFeature.description.indexOf(href) == -1)
{
- out.append("<a href=\"" + href + "\">" + label + "</a>");
+ out.append(" <a href=\"" + href + "\">" + label
+ + "</a>");
}
}
- if (features[j].getDescription().indexOf("</html>") == -1)
+ if (sequenceFeature.getDescription().indexOf("</html>") == -1)
{
out.append("</html>");
}
}
out.append(sequences[i].getName());
out.append("\t-1\t");
- out.append(features[j].begin);
+ out.append(sequenceFeature.begin);
out.append(TAB);
- out.append(features[j].end);
+ out.append(sequenceFeature.end);
out.append(TAB);
- out.append(features[j].type);
- if (!Float.isNaN(features[j].score))
+ out.append(sequenceFeature.type);
+ if (!Float.isNaN(sequenceFeature.score))
{
out.append(TAB);
- out.append(features[j].score);
+ out.append(sequenceFeature.score);
}
out.append(newline);
}
boolean includeNonPositionalFeatures)
{
StringBuilder out = new StringBuilder(256);
- out.append(String.format("%s %d\n", GFF_VERSION, gffVersion));
+ int version = gffVersion == 0 ? 2 : gffVersion;
+ out.append(String.format("%s %d\n", GFF_VERSION, version));
String source;
boolean isnonpos;
for (SequenceI seq : sequences)
} catch (IOException ex)
{
}
- ;
if (dta != null && dta.indexOf("*") > -1)
{
starterm = true;
// read as a FASTA (probably)
break;
}
- if ((data.indexOf("<") > -1)) // possible Markup Language data i.e HTML,
+ int lessThan = data.indexOf("<");
+ if ((lessThan > -1)) // possible Markup Language data i.e HTML,
// RNAML, XML
{
- // FIXME this is nuts - it consumes the rest of the file if no match
- boolean identified = false;
- do
- {
- if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
- {
- reply = HtmlFile.FILE_DESC;
- identified = true;
- break;
- }
-
- if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>"))
- {
- reply = "RNAML";
- identified = true;
- break;
- }
- } while ((data = source.nextLine()) != null);
-
- if (identified)
+ String upper = data.toUpperCase();
+ if (upper.substring(lessThan).startsWith("<HTML"))
{
+ reply = HtmlFile.FILE_DESC;
break;
}
- if (data == null)
+ if (upper.substring(lessThan).startsWith("<RNAML"))
{
+ reply = "RNAML";
break;
}
}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.renderer;
+
+import jalview.api.AlignViewportI;
+import jalview.datamodel.SequenceI;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Calculate and display alignment rulers
+ *
+ * @author jprocter
+ *
+ */
+public class ScaleRenderer
+{
+ /**
+ * calculate positions markers on the alignment ruler
+ *
+ * @param av
+ * @param startx
+ * left-most column in visible view
+ * @param endx
+ * - right-most column in visible view
+ * @return List { Object { .. } } Boolean: true/false for major/minor mark,
+ * Integer: marker position in alignment column coords, String: null
+ * or a String to be rendered at the position.
+ */
+ public static List<Object[]> calculateMarks(AlignViewportI av,
+ int startx, int endx)
+ {
+ new ArrayList<Object[]>();
+
+ int scalestartx = (startx / 10) * 10;
+
+ SequenceI refSeq = av.getAlignment().getSeqrep();
+ int refSp = 0, refStartI = 0, refEndI = -1;
+ if (refSeq != null)
+ {
+ // find bounds and set origin appopriately
+ // locate first visible position for this sequence
+ int[] refbounds = av.getColumnSelection()
+ .locateVisibleBoundsOfSequence(refSeq);
+
+ refSp = refbounds[0];
+ refStartI = refbounds[4];
+ refEndI = refbounds[5];
+ scalestartx = refSp + ((scalestartx - refSp) / 10) * 10;
+ }
+
+ if (refSeq == null && scalestartx % 10 == 0)
+ {
+ scalestartx += 5;
+ }
+ List<Object[]> marks = new ArrayList<Object[]>();
+ String string;
+ int refN, iadj;
+ // todo: add a 'reference origin column' to set column number relative to
+ for (int i = scalestartx; i < endx; i += 5)
+ {
+ Object[] amark = new Object[3];
+ if (((i - refSp) % 10) == 0)
+ {
+ if (refSeq == null)
+ {
+ iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1) + 1;
+ string = String.valueOf(iadj);
+ }
+ else
+ {
+ iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1);
+ refN = refSeq.findPosition(iadj);
+ // TODO show bounds if position is a gap
+ // - ie L--R -> "1L|2R" for
+ // marker
+ if (iadj < refStartI)
+ {
+ string = String.valueOf(iadj - refStartI);
+ }
+ else if (iadj > refEndI)
+ {
+ string = "+" + String.valueOf(iadj - refEndI);
+ }
+ else
+ {
+ string = String.valueOf(refN) + refSeq.getCharAt(iadj);
+ }
+ }
+ amark[0] = Boolean.TRUE;
+ amark[1] = Integer.valueOf(i - startx - 1);
+ amark[2] = string;
+
+ }
+ else
+ {
+ amark[0] = Boolean.FALSE;
+ amark[1] = Integer.valueOf(i - startx - 1);
+ amark[2] = null;
+ }
+ marks.add(amark);
+ }
+ return marks;
+ }
+
+}
}
/**
- * return a nominal colour for this feature
- *
- * @param featureType
- * @return standard color, or maximum colour for graduated colourscheme
- */
- public Color getColour(String featureType)
- {
- Object fc = getFeatureStyle(featureType);
-
- if (fc instanceof Color)
- {
- return (Color) fc;
- }
- else
- {
- if (fc instanceof GraduatedColor)
- {
- return ((GraduatedColor) fc).getMaxColor();
- }
- }
- throw new Error("Implementation Error: Unrecognised render object "
- + fc.getClass() + " for features of type " + featureType);
- }
-
- /**
* calculate the render colour for a specific feature using current feature
* settings.
*
return renderOrder != null;
}
+ /**
+ * Returns feature types in ordering of rendering, where last means on top
+ */
public List<String> getRenderOrder()
{
if (renderOrder == null)
while (en.hasNext())
{
String col = en.next();
- fcols.put(col, getColour(col));
+ fcols.put(col, featureColours.get(col));
}
return fcols;
}
}
+ @Test(groups={"Functional"})
+ public void testLocateVisibleBoundsPathologicals()
+ {
+ // test some pathological cases we missed
+ AlignmentI al = new Alignment(new SequenceI[] { new Sequence("refseqGaptest","KTDVTI----------NFI-----G----L")});
+ ColumnSelection cs = new ColumnSelection();
+ cs.hideInsertionsFor(al.getSequenceAt(0));
+ assertEquals(
+ "G",
+ ""
+ + al.getSequenceAt(0).getCharAt(
+ cs.adjustForHiddenColumns(9)));
+
+
+ }
@Test(groups = { "Functional" })
public void testHideColumns()
{
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.api.FeatureRenderer;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceDummy;
parseResult);
checkDatasetfromSimpleGff3(dataset);
}
+
+ @Test(groups = { "Functional" })
+ public void testPrintJalviewFormat() throws Exception
+ {
+ File f = new File("examples/uniref50.fa");
+ AlignmentI al = readAlignmentFile(f);
+ AlignFrame af = new AlignFrame(al, 500, 500);
+ Map<String, Object> colours = af.getFeatureRenderer()
+ .getFeatureColours();
+ String features = "METAL\tcc9900\n"
+ + "GAMMA-TURN\tred|0,255,255|20.0|95.0|below|66.0\n"
+ + "Pfam\tred\n"
+ + "STARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\n"
+ + "<html>Pfam domain<a href=\"http://pfam.sanger.ac.uk/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\n"
+ + "ENDGROUP\tuniprot\n";
+ FeaturesFile featuresFile = new FeaturesFile(features,
+ FormatAdapter.PASTE);
+ featuresFile.parse(al.getDataset(), colours, false);
+
+ /*
+ * first with no features displayed
+ */
+ FeatureRenderer fr = af.alignPanel.getFeatureRenderer();
+ Map<String, Object> visible = fr
+ .getDisplayedFeatureCols();
+ String exported = featuresFile.printJalviewFormat(
+ al.getSequencesArray(), visible);
+ String expected = "No Features Visible";
+ assertEquals(expected, exported);
+
+ /*
+ * set METAL (in uniprot group) and GAMMA-TURN visible, but not Pfam
+ */
+ fr.setVisible("METAL");
+ fr.setVisible("GAMMA-TURN");
+ visible = fr.getDisplayedFeatureCols();
+ exported = featuresFile.printJalviewFormat(al.getSequencesArray(),
+ visible);
+ expected = "METAL\tcc9900\n"
+ + "GAMMA-TURN\tff0000|00ffff|20.0|95.0|below|66.0\n"
+ + "\nSTARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\t0.0\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\t0.0\n"
+ + "ENDGROUP\tuniprot\n";
+ assertEquals(expected, exported);
+
+ /*
+ * now set Pfam visible
+ */
+ fr.setVisible("Pfam");
+ visible = fr.getDisplayedFeatureCols();
+ exported = featuresFile.printJalviewFormat(al.getSequencesArray(),
+ visible);
+ /*
+ * note the order of feature types is uncontrolled - derives from
+ * FeaturesDisplayed.featuresDisplayed which is a HashSet
+ */
+ expected = "METAL\tcc9900\n"
+ + "Pfam\tff0000\n"
+ + "GAMMA-TURN\tff0000|00ffff|20.0|95.0|below|66.0\n"
+ + "\nSTARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\t0.0\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\t0.0\n"
+ + "<html>Pfam domain<a href=\"http://pfam.sanger.ac.uk/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\t0.0\n"
+ + "ENDGROUP\tuniprot\n";
+ assertEquals(expected, exported);
+ }
}
*/
package jalview.io;
+import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
}
/**
- * Additional tests for (a) Jalview features file with no colour
- * specifications (old style 'groups' file) and (b) Jalview features file with
- * embedded GFF
+ * Additional tests for Jalview features file
*/
@Test(groups = "Functional")
public void testIdentify_featureFile()
{
IdentifyFile ider = new IdentifyFile();
- // Jalview format with features only, no feature colours
+ /*
+ * Jalview format with features only, no feature colours
+ */
String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
- Assert.assertEquals(IdentifyFile.FeaturesFile, ider.identify(data, AppletFormatAdapter.PASTE));
+ assertEquals(IdentifyFile.FeaturesFile,
+ ider.identify(data, AppletFormatAdapter.PASTE));
- // Jalview feature colour followed by GFF format feature data
+ /*
+ * Jalview feature colour followed by GFF format feature data
+ */
data = "METAL\tcc9900\n" + "GFF\n"
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
- Assert.assertEquals(IdentifyFile.FeaturesFile,
+ assertEquals(IdentifyFile.FeaturesFile,
+ ider.identify(data, AppletFormatAdapter.PASTE));
+
+ /*
+ * Feature with '<' in the name (JAL-2098)
+ */
+ data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
+ assertEquals(IdentifyFile.FeaturesFile,
ider.identify(data, AppletFormatAdapter.PASTE));
}
<string><![CDATA[664]]></string>
</property>
<property name="sourceName">
- <string><![CDATA[groovy-all-1.8.2.jar]]></string>
+ <string><![CDATA[groovy-all-2.4.6-indy.jar]]></string>
</property>
<property name="overrideUnixPermissions">
<boolean>false</boolean>
<boolean>true</boolean>
</property>
<property name="destinationName">
- <string><![CDATA[groovy-all-1.8.2.jar]]></string>
+ <string><![CDATA[groovy-all-2.4.6-indy.jar]]></string>
</property>
<property name="fileSize">
<long>6149494</long>