+ * flyweight access to positions in the alignment annotation row for RNA processing
+ * @author jimp
+ *
+ */
+ private class AnnotCharSequence implements CharSequence
+ {
+ int offset=0;
+ int max=0;
+
+ public AnnotCharSequence() {
+ this(0,annotations.length);
+ }
+ public AnnotCharSequence(int start, int end) {
+ offset=start;
+ max=end;
+ }
+ @Override
+ public CharSequence subSequence(int start, int end)
+ {
+ return new AnnotCharSequence(offset+start, offset+end);
+ }
+
+ @Override
+ public int length()
+ {
+ return max-offset;
+ }
+
+ @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);
+ }
+ public String toString()
+ {
+ char[] string=new char[max-offset];
+ int mx=annotations.length;
+
+ for (int i=offset;i<mx;i++)
+ {
+ String dc;
+ string[i]=(annotations[i]==null || (dc=annotations[i].displayCharacter.trim()).length()<1 )? '.' : dc.charAt(0);
+ }
+ return new String(string);
+ }
+ };
+
+ private long _lastrnaannot=-1;
+ public String getRNAStruc(){
+ if (isrna)
+ {
+ String rnastruc = new AnnotCharSequence().toString();
+ if (_lastrnaannot!=rnastruc.hashCode())
+ {
+ // ensure rna structure contacts are up to date
+ _lastrnaannot=rnastruc.hashCode();
+ _updateRnaSecStr(rnastruc);
+ }
+ return rnastruc;
+ }
+ return null;
+ }
+
+/**