JAL-2909 add sequence feature for quality
authorJim Procter <jprocter@issues.jalview.org>
Fri, 2 Mar 2018 10:35:28 +0000 (10:35 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 2 Mar 2018 10:35:28 +0000 (10:35 +0000)
src/jalview/io/BamFile.java

index 10e2d0e..c8bac62 100644 (file)
@@ -22,12 +22,14 @@ package jalview.io;
 
 import jalview.datamodel.CigarParser;
 import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.PrimitiveIterator.OfInt;
 import java.util.SortedMap;
 
 import htsjdk.samtools.SAMRecord;
@@ -137,7 +139,15 @@ public class BamFile extends AlignFile
                 rec.getReadString().toLowerCase());
         seq.setStart(1);
         seq.setEnd(rec.getReadLength());
-
+        OfInt q = rec.getBaseQualityString().chars()
+                .iterator();
+        int p = seq.getStart();
+        while (q.hasNext())
+        {
+          seq.addSequenceFeature(new SequenceFeature("QUALITY", "", p, p,
+                  (float) q.next() - ' ', "bamfile"));
+          p++;
+        }
         String newRead = parser.parseCigarToSequence(rec, insertions,
                 alignmentStart, seq);