1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
package artificialFastqGenerator;
import java.util.ArrayList;
/**
* An instance of this class corresponds to a read in an artificial fastq file. It has fields for its Nucleobase sequence,
* unique integer ID, the other read in the pair, its encoded quality scores, and the genotypes which actually get read (i.e.
* may contain error).
*
* Copyright (C) 2012 The Institute of Cancer Research (ICR).
*
* This file is part of ArtificialFastqGenerator v1.0.0.
*
* ArtificialFastqGenerator is free software: you can redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>
*
* Authour's contact email: Matthew.Frampton@icr.ac.uk
*/
public class Read extends AbstractRead {
private long uniqueID;
private Read pairedEndRead;
private boolean leftPEAndNeedsWriting;
private char[] encodedQualityScores;
private char[] genotypesThatAreRead;
private String machineLaneTileXYLorR = "HWI-ST745_0097:7:1101:";
/**
* Initialise a new Read object.
*
* @param sequence - the sequence of nucleobases in this read.
* @param uniqueID - the read's unique integer ID.
* @param pairedEndRead - the other read with which this one forms a pair.
* @param leftPEAndNeedsWriting - true if the read is a left read and needs writing, else false.
* @param encodedQualityScores - the encoded quality scores for this read.
* @param genotypesThatAreRead - the genotypes that get read.
* @param xCoordinate - the read's x-coordinate.
* @param yCoordinate - the read's y-coordinate.
*/
public Read(ArrayList<Nucleobase> sequence, long uniqueID, Read pairedEndRead, boolean leftPEAndNeedsWriting, char[] encodedQualityScores,
char[] genotypesThatAreRead, int xCoordinate, int yCoordinate) {
this.sequence = sequence;
this.uniqueID = uniqueID;
this.pairedEndRead = pairedEndRead;
updateNucleobaseCoverage(this);
this.leftPEAndNeedsWriting = leftPEAndNeedsWriting;
this.encodedQualityScores = encodedQualityScores;
this.genotypesThatAreRead = genotypesThatAreRead;
this.machineLaneTileXYLorR = this.machineLaneTileXYLorR + xCoordinate + ":" + yCoordinate + "#0/";
if (leftPEAndNeedsWriting) {
this.machineLaneTileXYLorR = this.machineLaneTileXYLorR + "1";
} else {
this.machineLaneTileXYLorR = this.machineLaneTileXYLorR + "2";
}
}
/**
* Set whether the Read object is a left read and needs writing.
*
* @param trueOrFalse - true if the read is a left read and needs writing, else false.
*/
public void setLeftReadAndNeedsWriting(boolean trueOrFalse) {
leftPEAndNeedsWriting = trueOrFalse;
}
/**
* Get whether the Read object is a left read and needs writing.
*
* @return leftPEAndNeedsWriting - whether the read is a left read and needs writing (hasn't been written yet), else false.
*/
public boolean isLeftReadAndNeedsWriting() {
return leftPEAndNeedsWriting;
}
/**
* Get the read with which this read object forms a pair.
*
* @return pairedEndRead - the read with which this read forms a pair.
*/
public Read getPairedEndRead() {
return pairedEndRead;
}
/**
* Set the read with which this read object forms a pair.
*
* @param pairedEndRead - the read with which this read forms a pair.
*/
public void setPairedEndRead(Read pairedEndRead) {
this.pairedEndRead = pairedEndRead;
}
/**
* For each of the reference genome nucleobases in this read, add
* the read into the nucleobase's covering reads ArrayList.
*
* @param read - this read.
*/
public void updateNucleobaseCoverage(Read read) {
for (Nucleobase nucleobase : read.getSequence()) {
if (!nucleobase.getCoveringReads().contains(read)) {
nucleobase.addCoveringRead(read);}
else {break;}
}
}
/**
* Get the string that represents this read object.
*
* @return returnString - the string that represents this read object.
*/
public String toString() {
String returnString = new String();
if (Main.outputFormat.equals(Main.DEFAULT_OUTPUT)) {
returnString = "@" + machineLaneTileXYLorR + "\n";
for (int i=0; i<genotypesThatAreRead.length; i++) {
returnString = returnString + genotypesThatAreRead[i];
}
returnString = returnString + "\n+" + machineLaneTileXYLorR + "\n";
for (int i=0; i<encodedQualityScores.length; i++) {
returnString = returnString + encodedQualityScores[i];
}
returnString = returnString + "\n";
} else {
returnString = getDebugString() + "\n";
}
return returnString;
}
/**
* Get the debug string for this read object.
*
* @return returnString - the debug string that represents this read object.
*/
public String getDebugString() {
String returnString = "";
for (Nucleobase nucleobase : sequence) {
returnString = returnString + nucleobase.toString();
}
if (Main.outputFormat.equals(Main.DEBUG_NUCLEOBASES_PE_IDS)) {
String pairedEndStr = "null";
if (!(pairedEndRead == null)) {
pairedEndStr = String.valueOf(pairedEndRead.uniqueID);
}
returnString = returnString + " ID:" + this.uniqueID + " PE_ID:" + pairedEndStr;
}
return returnString;
}
}
|