JAL-1065 per sequence and per-alignment scores added to annotation
[jalview.git] / src / jalview / io / TCoffeeScoreFile.java
index ed0f1d9..cf33671 100644 (file)
@@ -470,17 +470,30 @@ public class TCoffeeScoreFile extends AlignFile {
            Annotation[] annotations=new Annotation[al.getWidth()];
            for (int j=0;j<jSize;j++) {
              byte val = srow[j];
-             annotations[j]=new Annotation(s==null ? ""+val:null,s==null ? ""+val:null,(char) val,val*1f,val >= 0 && val < colors.length ? colors[val] : Color.white);
+             if (s!=null && jalview.util.Comparison.isGap(s.getCharAt(j)))
+             {
+               annotations[j]=null;
+               if (val>0)
+               {
+                 System.err.println("Warning: non-zero value for positional T-COFFEE score for gap at "+j+" in sequence "+s.getName());
+               }
+             } else {
+             annotations[j]=new Annotation(s==null ? ""+val:null,s==null ? ""+val:null,'\0',val*1f,val >= 0 && val < colors.length ? colors[val] : Color.white);
+             }
            }
            // this will overwrite any existing t-coffee scores for the alignment
            AlignmentAnnotation aa=al.findOrCreateAnnotation(TCOFFEE_SCORE,false,s,null);
            if (s!=null)
            {
              aa.label="T-COFFEE";
-             aa.description="Score for "+id.getKey();
+             aa.description=""+id.getKey();
              aa.annotations=annotations;
              aa.visible=false;
              aa.belowAlignment=false;
+             aa.setScore(header.getScoreFor(id.getKey()));
+              aa.createSequenceMapping(s, s.getStart(),true);
+              s.addAlignmentAnnotation(aa);
+              aa.adjustForAlignment();
            } else {
              aa.graph=AlignmentAnnotation.NO_GRAPH;
              aa.label="T-COFFEE";
@@ -488,12 +501,13 @@ public class TCoffeeScoreFile extends AlignFile {
              aa.annotations=annotations;
               aa.belowAlignment=true;
              aa.visible=true;
+             aa.setScore(header.getScoreAvg());
            }
            aa.showAllColLabels=true;
-            aa.setSequenceRef(s);
            aa.validateRangeAndDisplay();
            added=true;
          }
+         
          return added;
        }