@@ -63,7 +63,7 @@ public class ABITrace
6363
6464 //the next three lines are the important persistent data
6565 private String sequence ;
66- private int A [], G [], C [], T [], Basecalls [];
66+ private int A [], G [], C [], T [], Basecalls [], Qcalls [] ;
6767 private int TraceLength , SeqLength ;
6868
6969 //This is the actual file data.
@@ -78,7 +78,7 @@ public class ABITrace
7878 //allows ABITrace to handle that in a way that
7979 //is invisible to the user.
8080 private static int AbsIndexBase =26 ; //The file location of the Index pointer
81- private int IndexBase , PLOC ;
81+ private int IndexBase , PLOC , PCON ;
8282
8383 //the next declaration is for the actual file pointers
8484 private int DATA9 , DATA10 , DATA11 , DATA12 , PBAS2 , FWO ;
@@ -151,6 +151,12 @@ public ABITrace(byte[] ABIFileData)
151151 * array corresponds to an x-coordinate point in the graph that is a peak (a base location).
152152 */
153153 public int [] getBasecalls () { return Basecalls ; }
154+
155+ /**
156+ * Returns an <code>int[]</code> array that represents the quality - each int in the
157+ * array corresponds to an quality value 90-255) in the graph at a base location).
158+ */
159+ public int [] getQcalls () { return Qcalls ; }
154160
155161/**
156162 * Returns the original programatically determined (unedited) sequence as a <code>SymbolList</code>.
@@ -290,6 +296,7 @@ private void initData(byte[] fileData)
290296 {
291297 setIndex ();
292298 setBasecalls ();
299+ setQcalls ();
293300 setSeq ();
294301 setTraces ();
295302 }
@@ -409,6 +416,24 @@ private void setBasecalls()
409416 }
410417 }
411418 }
419+
420+ /**
421+ * Fetch the quality calls from the trace data.
422+ */
423+ private void setQcalls () {
424+ Qcalls = new int [SeqLength ];
425+ byte [] qq = new byte [SeqLength ];
426+ getSubArray (qq , PCON );
427+ DataInputStream dis = new DataInputStream (new ByteArrayInputStream (qq ));
428+ for (int i = 0 ; i <= SeqLength - 1 ; ++i ) {
429+ try {
430+ Qcalls [i ] = (int ) dis .readByte ();
431+ } catch (IOException e )//This shouldn't happen. If it does something must be seriously wrong.
432+ {
433+ throw new IllegalStateException ("Unexpected IOException encountered while manipulating internal streams." );
434+ }
435+ }
436+ }
412437
413438/**
414439 * Utility method to return an int beginning at <code>pointer</code> in the TraceData array.
@@ -477,11 +502,11 @@ private double calculateScale(int height)
477502 */
478503 private void setIndex ()
479504 {
480- int DataCounter , PBASCounter , PLOCCounter , NumRecords ;
505+ int DataCounter , PBASCounter , PLOCCounter , PCONCounter , NumRecords ;
481506 byte [] RecNameArray = new byte [4 ];
482507 String RecName ;
483508
484- DataCounter = 0 ; PBASCounter = 0 ; PLOCCounter = 0 ;
509+ DataCounter = 0 ; PBASCounter = 0 ; PLOCCounter = 0 ; PCONCounter = 0 ;
485510
486511 IndexBase = getIntAt (AbsIndexBase + MacJunk );
487512 NumRecords = getIntAt (AbsIndexBase - 8 + MacJunk );
@@ -516,6 +541,12 @@ private void setIndex()
516541 if (PLOCCounter == 2 )
517542 PLOC = IndexBase + (record * 28 ) + 20 ;
518543 }
544+ if (RecName .equals ("PCON" ))
545+ {
546+ ++PCONCounter ;
547+ if (PCONCounter == 2 )
548+ PCON = IndexBase + (record * 28 ) + 20 ;
549+ }
519550
520551 } //next record
521552 TraceLength = getIntAt (DATA12 - 8 );
@@ -526,6 +557,7 @@ private void setIndex()
526557 DATA11 = getIntAt (DATA11 ) + MacJunk ;
527558 DATA12 = getIntAt (DATA12 ) + MacJunk ;
528559 PBAS2 = getIntAt (PBAS2 ) + MacJunk ;
560+ PCON = getIntAt (PCON ) + MacJunk ;
529561 }
530562
531563/**
0 commit comments