2009-05-15 00:52:03 +08:00
|
|
|
package org.broadinstitute.sting.secondarybase;
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
|
|
|
|
* RawRead represents lane and tile coordinates, raw intensities, read bases, and quality scores
|
|
|
|
|
*
|
|
|
|
|
* @author Kiran Garimella
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public class RawRead {
|
|
|
|
|
private byte lane;
|
|
|
|
|
private short tile;
|
|
|
|
|
private short x;
|
|
|
|
|
private short y;
|
|
|
|
|
|
|
|
|
|
private byte[] sequence;
|
|
|
|
|
private byte[] quals;
|
|
|
|
|
private short[][] intensities;
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
|
|
|
|
* Construct a raw read from the output of a PasteParser (in the order of int, seq, prb).
|
|
|
|
|
* Takes data within specified cycle ranges.
|
|
|
|
|
*
|
|
|
|
|
* @param pastedReadString the 3x(fragment length) output array from the PasteParser.
|
|
|
|
|
* @param cycleBegin the start cycle for the read (0-based, inclusive)
|
|
|
|
|
* @param cycleEnd the end cycle for the read (0-based, inclusive)
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public RawRead(String[][] pastedReadString, int cycleBegin, int cycleEnd) {
|
|
|
|
|
lane = Byte.valueOf(pastedReadString[0][0]);
|
|
|
|
|
tile = Short.valueOf(pastedReadString[0][1]);
|
|
|
|
|
x = Short.valueOf(pastedReadString[0][2]);
|
|
|
|
|
y = Short.valueOf(pastedReadString[0][3]);
|
|
|
|
|
|
2009-05-20 08:09:20 +08:00
|
|
|
sequence = pastedReadString[1][4].substring(cycleBegin, cycleEnd + 1).getBytes();
|
2009-05-15 00:52:03 +08:00
|
|
|
|
|
|
|
|
quals = new byte[sequence.length];
|
|
|
|
|
intensities = new short[sequence.length][4];
|
|
|
|
|
|
2009-05-20 08:09:20 +08:00
|
|
|
for (int cycle = cycleBegin, offset = 0; cycle <= cycleEnd; cycle++, offset++) {
|
2009-05-15 00:52:03 +08:00
|
|
|
byte maxQual = -50;
|
|
|
|
|
|
|
|
|
|
for (int fullReadIndex = 4*cycle; fullReadIndex < 4*cycle + 4; fullReadIndex++) {
|
|
|
|
|
byte qual = Byte.valueOf(pastedReadString[2][fullReadIndex]);
|
|
|
|
|
|
|
|
|
|
if (qual > maxQual) { maxQual = qual; }
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-20 08:09:20 +08:00
|
|
|
quals[offset] = maxQual >= 0 ? maxQual : 0;
|
2009-05-15 00:52:03 +08:00
|
|
|
|
|
|
|
|
for (int fullReadIndex = 4*cycle + 4, channel = 0; fullReadIndex < 4*cycle + 8; fullReadIndex++, channel++) {
|
|
|
|
|
double doubleChannelIntensity = Double.valueOf(pastedReadString[0][fullReadIndex]);
|
|
|
|
|
short shortChannelIntensity = (short) doubleChannelIntensity;
|
|
|
|
|
|
2009-05-20 08:09:20 +08:00
|
|
|
intensities[offset][channel] = shortChannelIntensity;
|
2009-05-15 00:52:03 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get lane number of read.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return lane number of read
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public byte getLane() { return lane; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get tile number of read.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return tile number of read
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public int getTile() { return tile; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get x-coordinate of read.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return x-coordinate of read
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public int getXCoordinate() { return x; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get y-coordinate of read.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return y-coordinate of read
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public int getYCoordinate() { return y; }
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get read key (lane:tile:x:y).
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return read key (lane:tile:x:y)
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public String getReadKey() { return String.format("%d:%d:%d:%d", lane, tile, x, y); }
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get the read sequence between the cycles specified in the constructor as a byte array.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return read sequence
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public byte[] getSequence() { return sequence; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Set the read sequence from a byte array.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @param sequence the read sequence in byte array form
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public void setSequence(byte[] sequence) { this.sequence = sequence; }
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get the read sequence as a String.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
2009-05-22 03:40:47 +08:00
|
|
|
* @return the read sequence in String form
|
2009-05-15 02:58:43 +08:00
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public String getSequenceAsString() {
|
|
|
|
|
return new String(getSequence());
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get the quals.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return a byte array of quals
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public byte[] getQuals() { return quals; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Set the quals.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @param quals a byte array of quals
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public void setQuals(byte[] quals) { this.quals = quals; }
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get the raw read intensities.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return the (readLength)x(numChannels) array of raw intensities
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public short[][] getIntensities() { return intensities; }
|
2009-05-15 02:58:43 +08:00
|
|
|
|
|
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Set the raw intensities.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @param intensities the (readLength)x(numChannels) array of raw intensities
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public void setIntensities(short[][] intensities) { this.intensities = intensities; }
|
|
|
|
|
|
2009-05-15 02:58:43 +08:00
|
|
|
/**
|
2009-05-22 03:40:47 +08:00
|
|
|
* Get the read length.
|
2009-05-15 02:58:43 +08:00
|
|
|
*
|
|
|
|
|
* @return the read length
|
|
|
|
|
*/
|
2009-05-15 00:52:03 +08:00
|
|
|
public int getReadLength() { return sequence.length; }
|
|
|
|
|
}
|