import jalview.analysis.SecStrConsensus.SimpleBP;
import jalview.analysis.WUSSParseException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/** Array of annotations placed in the current coordinate system */
public Annotation[] annotations;
- public ArrayList<SimpleBP> bps = null;
+ public List<SimpleBP> bps = null;
/**
* RNA secondary structure contact positions
{
try
{
- _rnasecstr = Rna.GetBasePairs(RNAannot);
- bps = Rna.GetModeleBP(RNAannot);
+ bps = Rna.getModeleBP(RNAannot);
+ _rnasecstr = Rna.getBasePairs(bps);
invalidrnastruc = -1;
} catch (WUSSParseException px)
{
// JBPNote: what does this do ?
public void ConcenStru(CharSequence RNAannot) throws WUSSParseException
{
- bps = Rna.GetModeleBP(RNAannot);
+ bps = Rna.getModeleBP(RNAannot);
}
/**
this(0, annotations.length);
}
- public AnnotCharSequence(int start, int end)
+ AnnotCharSequence(int start, int end)
{
offset = start;
max = end;
*/
package jalview.io;
-import jalview.analysis.SecStrConsensus.SimpleBP;
+import jalview.analysis.Rna;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
import com.stevesoft.pat.Regex;
*
* @see jalview.io.AlignFile#parse()
*/
+ @Override
public void parse() throws IOException
{
if (System.getProperty("java.version").indexOf("1.6") > -1
result = RNAFactory.loadSecStrRNAML(getReader());
- ArrayList<ArrayList> allarray = new ArrayList();
- ArrayList<ArrayList<SimpleBP>> BP = new ArrayList();
- ArrayList strucinarray = new ArrayList();
- SequenceI[] seqs = new SequenceI[result.size()];
+ // ArrayList<ArrayList> allarray = new ArrayList();
+ // ArrayList<ArrayList<SimpleBP>> BP = new ArrayList();
+ // ArrayList strucinarray = new ArrayList();
+ SequenceI[] sqs = new SequenceI[result.size()];
for (int i = 0; i < result.size(); i++)
{
id += "." + i;
}
}
- seqs[i] = new Sequence(id, seq, begin, end);
+ sqs[i] = new Sequence(id, seq, begin, end);
- seqs[i].setEnd(seqs[i].findPosition(seqs[i].getLength()));
+ sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength()));
String[] annot = new String[rna.length()];
Annotation[] ann = new Annotation[rna.length()];
}
for (int k = 0; k < rna.length(); k++)
{
- ann[k] = new Annotation(annot[k], "",
- jalview.schemes.ResidueProperties.getRNASecStrucState(
- annot[k]).charAt(0), 0f);
+ ann[k] = new Annotation(annot[k], "", Rna.getRNASecStrucState(
+ annot[k]).charAt(0), 0f);
}
AlignmentAnnotation align = new AlignmentAnnotation(
+ current.getID()
: "", ann);
- seqs[i].addAlignmentAnnotation(align);
- seqs[i].setRNA(result.get(i));
+ sqs[i].addAlignmentAnnotation(align);
+ sqs[i].setRNA(result.get(i));
- allarray.add(strucinarray);
+ // allarray.add(strucinarray);
annotations.addElement(align);
- BP.add(align.bps);
+ // BP.add(align.bps);
}
- setSeqs(seqs);
+ setSeqs(sqs);
}
public static String print(SequenceI[] s)
return "not yet implemented";
}
+ @Override
public String print()
{
System.out.print("print :");
return print(getSeqsAsArray());
}
- public ArrayList getRNA()
+ public List<RNA> getRNA()
{
return result;
}
*/
package jalview.io;
+import jalview.analysis.Rna;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.schemes.ResidueProperties;
import jalview.util.Format;
import jalview.util.MessageManager;
*/
public class StockholmFile extends AlignFile
{
- // static Logger logger = Logger.getLogger("jalview.io.StockholmFile");
- protected ArrayList<RNA> result;
+ private static final Regex OPEN_PAREN = new Regex("(<|\\[)", "(");
+
+ private static final Regex CLOSE_PAREN = new Regex("(>|\\])", ")");
+
+ private static final Regex DETECT_BRACKETS = new Regex(
+ "(<|>|\\[|\\]|\\(|\\))");
StringBuffer out; // output buffer
super(source);
}
+ @Override
public void initData()
{
super.initData();
fr = new FileReader(inFile);
BufferedReader r = new BufferedReader(fr);
- result = null;
+ List<RNA> result = null;
try
{
result = RNAFactory.loadSecStrStockholm(r);
for (int k = 0; k < rna.length(); k++)
{
- ann[k] = new Annotation(annot[k], "",
- jalview.schemes.ResidueProperties.getRNASecStrucState(
- annot[k]).charAt(0), 0f);
+ ann[k] = new Annotation(annot[k], "", Rna.getRNASecStrucState(
+ annot[k]).charAt(0), 0f);
}
AlignmentAnnotation align = new AlignmentAnnotation("Sec. str.",
* @throws IOException
* If there is an error with the input file
*/
+ @Override
public void parse() throws IOException
{
StringBuffer treeString = new StringBuffer();
}
protected static AlignmentAnnotation parseAnnotationRow(
- Vector annotation, String label, String annots)
+ Vector<AlignmentAnnotation> annotation, String label,
+ String annots)
{
String convert1, convert2 = null;
- // Convert all bracket types to parentheses
- Regex openparen = new Regex("(<|\\[)", "(");
- Regex closeparen = new Regex("(>|\\])", ")");
-
- // Detect if file is RNA by looking for bracket types
- Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
-
- convert1 = openparen.replaceAll(annots);
- convert2 = closeparen.replaceAll(convert1);
+ convert1 = OPEN_PAREN.replaceAll(annots);
+ convert2 = CLOSE_PAREN.replaceAll(convert1);
annots = convert2;
String type = label;
{
// if (" .-_".indexOf(pos) == -1)
{
- if (detectbrackets.search(pos))
+ if (DETECT_BRACKETS.search(pos))
{
- ann.secondaryStructure = jalview.schemes.ResidueProperties
- .getRNASecStrucState(pos).charAt(0);
+ ann.secondaryStructure = Rna.getRNASecStrucState(
+ pos).charAt(0);
}
else
{
- ann.secondaryStructure = jalview.schemes.ResidueProperties
- .getDssp3state(pos).charAt(0);
+ ann.secondaryStructure = ResidueProperties.getDssp3state(pos)
+ .charAt(0);
}
if (ann.secondaryStructure == pos.charAt(0))
els[i] = ann;
}
AlignmentAnnotation annot = null;
- Enumeration e = annotation.elements();
+ Enumeration<AlignmentAnnotation> e = annotation.elements();
while (e.hasMoreElements())
{
- annot = (AlignmentAnnotation) e.nextElement();
+ annot = e.nextElement();
if (annot.label.equals(type))
{
break;
return seq;
}
+ @Override
public String print()
{
out = new StringBuffer();
}
private static Hashtable typeIds = null;
+
static
{
if (typeIds == null)
import jalview.analysis.AAFrequency;
import jalview.analysis.CodingUtils;
+import jalview.analysis.Rna;
import jalview.analysis.StructureFrequency;
import jalview.api.AlignViewportI;
import jalview.datamodel.AlignmentAnnotation;
import java.util.BitSet;
import java.util.Hashtable;
-import com.stevesoft.pat.Regex;
-
public class AnnotationRenderer
{
private static final int UPPER_TO_LOWER = 'a' - 'A'; // 32
this.debugRedraw = debugRedraw;
}
- public void drawStemAnnot(Graphics g, Annotation[] row_annotations,
+ void drawStemAnnot(Graphics g, Annotation[] row_annotations,
int lastSSX, int x, int y, int iconOffset, int startRes,
int column, boolean validRes, boolean validEnd)
{
int sCol = (lastSSX / charWidth) + startRes;
int x1 = lastSSX;
int x2 = (x * charWidth);
- Regex closeparen = new Regex("(\\))");
char dc = (column == 0 || row_annotations[column - 1] == null) ? ' '
: row_annotations[column - 1].secondaryStructure;
boolean diffdownstream = !validRes || !validEnd
|| row_annotations[column] == null
|| dc != row_annotations[column].secondaryStructure;
- // System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
- // If a closing base pair half of the stem, display a backward arrow
- if (column > 0 && ResidueProperties.isCloseParenRNA(dc))
- {
+ if (column > 0 && Rna.isClosingParenthesis(dc))
+ {
if (diffupstream)
// if (validRes && column>1 && row_annotations[column-2]!=null &&
// dc.equals(row_annotations[column-2].displayCharacter))
{
+ /*
+ * if new annotation with a closing base pair half of the stem,
+ * display a backward arrow
+ */
g.fillPolygon(new int[] { lastSSX + 5, lastSSX + 5, lastSSX },
new int[] { y + iconOffset, y + 14 + iconOffset,
y + 8 + iconOffset }, 3);
}
else
{
-
// display a forward arrow
if (diffdownstream)
{
+ /*
+ * if annotation ending with an opeing base pair half of the stem,
+ * display a forward arrow
+ */
g.fillPolygon(new int[] { x2 - 5, x2 - 5, x2 }, new int[] {
y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
x2 -= 5;
*/
private boolean canClip = false;
- public void drawNotCanonicalAnnot(Graphics g, Color nonCanColor,
+ void drawNotCanonicalAnnot(Graphics g, Color nonCanColor,
Annotation[] row_annotations, int lastSSX, int x, int y,
int iconOffset, int startRes, int column, boolean validRes,
boolean validEnd)
int sCol = (lastSSX / charWidth) + startRes;
int x1 = lastSSX;
int x2 = (x * charWidth);
- Regex closeparen = new Regex("}|]|<|[a-z]");
String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
: row_annotations[column - 1].displayCharacter;
|| !dc.equals(row_annotations[column].displayCharacter);
// System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
// If a closing base pair half of the stem, display a backward arrow
- if (column > 0 && closeparen.search(dc))// closeletter_b.search(dc)||closeletter_c.search(dc)||closeletter_d.search(dc)||closecrochet.search(dc))
- // )
+ if (column > 0 && Rna.isClosingParenthesis(dc.charAt(0)))
{
if (diffupstream)
* @param column
* @return
*/
- public int[] getProfileFor(AlignmentAnnotation aa, int column)
+ int[] getProfileFor(AlignmentAnnotation aa, int column)
{
// TODO : consider refactoring the global alignment calculation
// properties/rendering attributes as a global 'alignment group' which holds
private Color sdNOTCANONICAL_COLOUR;
- public void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
+ void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
int x, int y, int iconOffset, int startRes, int column,
boolean validRes, boolean validEnd)
{
g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2);
}
- public void drawSheetAnnot(Graphics g, Annotation[] row,
+ void drawSheetAnnot(Graphics g, Annotation[] row,
int lastSSX, int x, int y, int iconOffset, int startRes, int column,
boolean validRes, boolean validEnd)
}
- public void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
+ void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
int x, int y, int iconOffset, int startRes, int column,
boolean validRes, boolean validEnd)
{
g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
}
- public void drawLineGraph(Graphics g, AlignmentAnnotation _aa,
+ void drawLineGraph(Graphics g, AlignmentAnnotation _aa,
Annotation[] aa_annotations, int sRes, int eRes, int y,
float min, float max, int graphHeight)
{
}
}
- public void drawBarGraph(Graphics g, AlignmentAnnotation _aa,
+ void drawBarGraph(Graphics g, AlignmentAnnotation _aa,
Annotation[] aa_annotations, int sRes, int eRes, float min,
float max, int y, boolean renderHistogram, boolean renderProfile,
boolean normaliseProfile)
scl = htn * scale * profl[c++];
lm = ofont.getLineMetrics(dc, 0, 1, g.getFontMetrics()
.getFontRenderContext());
- g.setFont(ofont.deriveFont(AffineTransform.getScaleInstance(
- wdth, scl / lm.getAscent())));
+ Font font = ofont.deriveFont(AffineTransform.getScaleInstance(
+ wdth, scl / lm.getAscent()));
+ g.setFont(font);
lm = g.getFontMetrics().getLineMetrics(dc, 0, 1, g);
// Debug - render boxes around characters
return ss.toString();
}
- /**
- * Used by getRNASecStrucState
- *
- */
- public static Hashtable<String, String> toRNAssState;
-
- public static boolean RNAcloseParen[] = new boolean[255];
- static
- {
- toRNAssState = new Hashtable<String, String>();
- toRNAssState.put(")", "(");
- toRNAssState.put("(", "(");
- toRNAssState.put("]", "[");
- toRNAssState.put("[", "[");
- toRNAssState.put("{", "{");
- toRNAssState.put("}", "{");
- toRNAssState.put(">", ">");
- toRNAssState.put("<", ">");
- toRNAssState.put("A", "A");
- toRNAssState.put("a", "A");
- toRNAssState.put("B", "B");
- toRNAssState.put("b", "B");
- toRNAssState.put("C", "C");
- toRNAssState.put("c", "C");
- toRNAssState.put("D", "D");
- toRNAssState.put("d", "D");
- toRNAssState.put("E", "E");
- toRNAssState.put("e", "E");
- toRNAssState.put("F", "F");
- toRNAssState.put("f", "F");
- toRNAssState.put("G", "G");
- toRNAssState.put("g", "G");
- toRNAssState.put("H", "H");
- toRNAssState.put("h", "H");
- toRNAssState.put("I", "I");
- toRNAssState.put("i", "I");
- toRNAssState.put("J", "J");
- toRNAssState.put("j", "J");
- toRNAssState.put("K", "K");
- toRNAssState.put("k", "K");
- toRNAssState.put("L", "L");
- toRNAssState.put("l", "L");
- toRNAssState.put("M", "M");
- toRNAssState.put("m", "M");
- toRNAssState.put("N", "N");
- toRNAssState.put("n", "N");
- toRNAssState.put("O", "O");
- toRNAssState.put("o", "O");
- toRNAssState.put("P", "P");
- toRNAssState.put("p", "P");
- toRNAssState.put("Q", "Q");
- toRNAssState.put("q", "Q");
- toRNAssState.put("R", "R");
- toRNAssState.put("r", "R");
- toRNAssState.put("S", "S");
- toRNAssState.put("s", "S");
- toRNAssState.put("T", "T");
- toRNAssState.put("t", "T");
- toRNAssState.put("U", "U");
- toRNAssState.put("u", "U");
- toRNAssState.put("V", "V");
- toRNAssState.put("v", "V");
- toRNAssState.put("W", "W");
- toRNAssState.put("w", "W");
- toRNAssState.put("X", "X");
- toRNAssState.put("x", "X");
- toRNAssState.put("Y", "Y");
- toRNAssState.put("y", "Y");
- toRNAssState.put("Z", "Z");
- toRNAssState.put("z", "Z");
- for (int p = 0; p < RNAcloseParen.length; p++)
- {
- RNAcloseParen[p] = false;
- }
- for (String k : toRNAssState.keySet())
- {
- RNAcloseParen[k.charAt(0)] = k.charAt(0) != toRNAssState.get(k)
- .charAt(0);
- }
- }
-
static
{
modifications.put("MSE", "MET"); // Selenomethionine
return canonical == null ? aa : canonical;
}
- /**
- * translate to RNA secondary structure representation
- *
- * @param ssstring
- * @return ssstring as a RNA-state secondary structure assignment.
- */
- public static String getRNASecStrucState(String ssstring)
- {
- if (ssstring == null)
- {
- return null;
- }
- StringBuffer ss = new StringBuffer();
- for (int i = 0; i < ssstring.length(); i++)
- {
- String ssc = ssstring.substring(i, i + 1);
- if (toRNAssState.containsKey(ssc))
- {
- // valid ss character - so return it
- ss.append(ssc); // (String) toRNAssState.get(ssc));
- }
- else
- {
- ss.append(" ");
- }
- }
- return ss.toString();
- }
-
- public static boolean isCloseParenRNA(char dc)
- {
- return RNAcloseParen[dc];
- }
-
// main method generates perl representation of residue property hash
// / cut here
public static void main(String[] args)