X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentAnnotation.java;h=b60813950ae4c84a22587a8e3c769765fa0a966d;hb=960206d9ae05d85b42552025c3dec4b5f7b14c15;hp=0207575aea6f9c2dda68a4e6de94f6ba03428c9d;hpb=7d3c15518c8a237ff2ef0c135b6553891485462d;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 0207575..b608139 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,19 +20,18 @@ */ package jalview.datamodel; -import jalview.analysis.Rna; -import jalview.analysis.SecStrConsensus.SimpleBP; -import jalview.analysis.WUSSParseException; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; -import java.util.Hashtable; +import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; +import jalview.analysis.Rna; +import jalview.analysis.SecStrConsensus.SimpleBP; +import jalview.analysis.WUSSParseException; + /** * DOCUMENT ME! * @@ -41,6 +40,15 @@ import java.util.Map.Entry; */ public class AlignmentAnnotation { + /* + * Identifers for different types of profile data + */ + public static final int SEQUENCE_PROFILE = 0; + + public static final int STRUCTURE_PROFILE = 1; + + public static final int CDNA_PROFILE = 2; + /** * If true, this annotations is calculated every edit, eg consensus, quality * or conservation graphs @@ -75,9 +83,10 @@ public class AlignmentAnnotation public SequenceFeature[] _rnasecstr = null; /** - * position of annotation resulting in invalid WUSS parsing or -1 + * position of annotation resulting in invalid WUSS parsing or -1. -2 means + * there was no RNA structure in this annotation */ - private long invalidrnastruc = -1; + private long invalidrnastruc = -2; /** * Updates the _rnasecstr field Determines the positions that base pair and @@ -118,6 +127,7 @@ public class AlignmentAnnotation private void _markRnaHelices() { + int mxval = 0; // Figure out number of helices // Length of rnasecstr is the number of pairs of positions that base pair // with each other in the secondary structure @@ -133,6 +143,10 @@ public class AlignmentAnnotation try { val = Integer.valueOf(_rnasecstr[x].getFeatureGroup()); + if (mxval < val) + { + mxval = val; + } } catch (NumberFormatException q) { } @@ -141,14 +155,15 @@ public class AlignmentAnnotation annotations[_rnasecstr[x].getBegin()].value = val; annotations[_rnasecstr[x].getEnd()].value = val; - annotations[_rnasecstr[x].getBegin()].displayCharacter = "" + val; - annotations[_rnasecstr[x].getEnd()].displayCharacter = "" + val; + // annotations[_rnasecstr[x].getBegin()].displayCharacter = "" + val; + // annotations[_rnasecstr[x].getEnd()].displayCharacter = "" + val; } + setScore(mxval); } /** * map of positions in the associated annotation */ - public java.util.Hashtable sequenceMapping; + private Map sequenceMapping; /** DOCUMENT ME!! */ public float graphMin; @@ -486,13 +501,13 @@ public class AlignmentAnnotation @Override public char charAt(int index) { - String dc; return ((index + offset < 0) || (index + offset) >= max - || annotations[index + offset] == null || (dc = annotations[index - + offset].displayCharacter.trim()).length() < 1) ? '.' : dc - .charAt(0); + || annotations[index + offset] == null || (annotations[index + + offset].secondaryStructure < ' ') ? ' ' + : annotations[index + offset].secondaryStructure); } + @Override public String toString() { char[] string = new char[max - offset]; @@ -500,9 +515,8 @@ public class AlignmentAnnotation for (int i = offset; i < mx; i++) { - String dc; - string[i] = (annotations[i] == null || (dc = annotations[i].displayCharacter - .trim()).length() < 1) ? '.' : dc.charAt(0); + string[i] = (annotations[i] == null || (annotations[i].secondaryStructure < 32)) ? ' ' + : annotations[i].secondaryStructure; } return new String(string); } @@ -705,12 +719,13 @@ public class AlignmentAnnotation if (annotation.sequenceMapping != null) { Integer p = null; - sequenceMapping = new Hashtable(); - Enumeration pos = annotation.sequenceMapping.keys(); - while (pos.hasMoreElements()) + sequenceMapping = new HashMap(); + Iterator pos = annotation.sequenceMapping.keySet() + .iterator(); + while (pos.hasNext()) { // could optimise this! - p = (Integer) pos.nextElement(); + p = pos.next(); Annotation a = annotation.sequenceMapping.get(p); if (a == null) { @@ -784,11 +799,11 @@ public class AlignmentAnnotation int epos = sequenceRef.findPosition(endRes); if (sequenceMapping != null) { - Hashtable newmapping = new Hashtable(); - Enumeration e = sequenceMapping.keys(); - while (e.hasMoreElements()) + Map newmapping = new HashMap(); + Iterator e = sequenceMapping.keySet().iterator(); + while (e.hasNext()) { - Integer pos = (Integer) e.nextElement(); + Integer pos = e.next(); if (pos.intValue() >= spos && pos.intValue() <= epos) { newmapping.put(pos, sequenceMapping.get(pos)); @@ -831,9 +846,10 @@ public class AlignmentAnnotation * * @return DOCUMENT ME! */ + @Override public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(256); for (int i = 0; i < annotations.length; i++) { @@ -906,7 +922,7 @@ public class AlignmentAnnotation { return; } - sequenceMapping = new java.util.Hashtable(); + sequenceMapping = new HashMap(); int seqPos; @@ -1218,7 +1234,7 @@ public class AlignmentAnnotation .getTo() == sq.getDatasetSequence()) : false; // TODO build a better annotation element map and get rid of annotations[] - Hashtable mapForsq = new Hashtable(); + Map mapForsq = new HashMap(); if (sequenceMapping != null) { if (sp2sq != null) @@ -1270,7 +1286,8 @@ public class AlignmentAnnotation { if (mapping != null) { - Hashtable old = sequenceMapping, remap = new Hashtable(); + Map old = sequenceMapping; + Map remap = new HashMap(); int index = -1; for (int mp[] : mapping) { @@ -1342,8 +1359,21 @@ public class AlignmentAnnotation { if (properties == null) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } return properties.keySet(); } + + /** + * Returns the Annotation for the given sequence position (base 1) if any, + * else null + * + * @param position + * @return + */ + public Annotation getAnnotationForPosition(int position) + { + return sequenceMapping == null ? null : sequenceMapping.get(position); + + } }