本文整理汇总了Java中htsjdk.samtools.fastq.FastqRecord.getBaseQualityString方法的典型用法代码示例。如果您正苦于以下问题:Java FastqRecord.getBaseQualityString方法的具体用法?Java FastqRecord.getBaseQualityString怎么用?Java FastqRecord.getBaseQualityString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.fastq.FastqRecord
的用法示例。
在下文中一共展示了FastqRecord.getBaseQualityString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewFastqRecordWithAdditionalAnnotation
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
private static FastqRecord createNewFastqRecordWithAdditionalAnnotation(FastqRecord record, String additionalAnnotation, String sequence, String quality) {
String seqHeaderPrefix = record.getReadHeader();
String seqLine = record.getReadString();
if (sequence != null) {
seqLine = sequence;
}
String qualHeaderPrefix = record.getBaseQualityHeader();
if (qualHeaderPrefix != null) {
qualHeaderPrefix += additionalAnnotation;
} else {
qualHeaderPrefix = additionalAnnotation;
}
String qualLine = record.getBaseQualityString();
if (quality != null) {
qualLine = quality;
}
FastqRecord newRecord = new FastqRecord(seqHeaderPrefix, seqLine, qualHeaderPrefix, qualLine);
return newRecord;
}
示例2: reverseCompliment
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
public static void reverseCompliment(File inputFastqFile, File outputFastqFile) {
try (FastqWriter writer = new FastqWriter(outputFastqFile)) {
try (FastqReader reader = new FastqReader(inputFastqFile)) {
while (reader.hasNext()) {
FastqRecord record = reader.next();
ISequence sequence = new NucleotideCodeSequence(record.getReadString());
ISequence newSequence = sequence.getCompliment();
String qualityString = record.getBaseQualityString();
String newQualityString = qualityString;// StringUtil.reverse(qualityString);
FastqRecord newRecord = new FastqRecord(record.getReadHeader(), newSequence.toString(), record.getBaseQualityHeader(), newQualityString);
writer.write(newRecord);
}
}
}
}
示例3: getNextReadPair
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
* get the next entry of PBSim output
*
* @return null if no more entries, otherwise a new instance of SimulatedReadPair (read1 is valid and read2 is null)
*/
@Override
public SimulatedReadPair getNextReadPair() throws IOException {
if (fastq.hasNext()) {
if (!maf.hasNext()) throw new RuntimeException(); //should formally use zipped iterator
FastqRecord fastqEntry = fastq.next();
MafRecord mafEntry = maf.next();
SimulatedRead read = new SimulatedRead();
read.fragment = 1; //always read-1 since there is no pair-ended-ness
read.setReadId(fastqEntry.getReadHeader());
read.sequence = fastqEntry.getReadString();
read.quality = fastqEntry.getBaseQualityString();
if (mafEntry.size() != 2) throw new RuntimeException("unexpected MAF data");
if (!mafEntry.get(0).src.equals("ref")) throw new RuntimeException("unexpected MAF data");
if (!mafEntry.get(1).src.equals(read.getReadId())) throw new RuntimeException("unmatched read names");
//read name is S%d_%d, where the first integer is CHR index and second integer is read number
final String[] tags = read.getReadId().substring(1).split("_");
if (tags.length != 2) throw new RuntimeException("unexpected MAF data");
final GenomeLocation loc = new GenomeLocation(
idx2Chr.get(Integer.parseInt(tags[0])),
mafEntry.get(0).start0 + 1, // 0-base to 1-base conversion
mafEntry.get(0).strand ? 0 : 1); // MAF's "+" maps to 0, "-" to 1
read.locs1.add(loc);
read.origLocs1.add(loc);
read.alignedBases1 = mafEntry.get(1).size;
return new SimulatedReadPair(read);
} else {
return null;
}
}
示例4: write
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
public void write(FastqRecord record) {
try {
String recordAsString = FastqConstants.SEQUENCE_HEADER + record.getReadHeader() + StringUtil.NEWLINE + record.getReadString() + StringUtil.NEWLINE + FastqConstants.QUALITY_HEADER
+ (record.getBaseQualityHeader() == null ? "" : record.getBaseQualityHeader()) + StringUtil.NEWLINE + record.getBaseQualityString() + StringUtil.NEWLINE;
writer.write(recordAsString.getBytes());
} catch (IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例5: trim
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
static FastqRecord trim(FastqRecord record, int firstBaseToKeep, int lastBaseToKeep, boolean performThreePrimeTrimming, int recordIndex) {
String readName = record.getReadHeader();
String readString = record.getReadString();
String readQuality = record.getBaseQualityString();
TrimmedRead trimmedRead = trim(readString, readQuality, firstBaseToKeep, lastBaseToKeep, performThreePrimeTrimming);
FastqRecord newRecord = new FastqRecord(readName, trimmedRead.getTrimmedReadString(), record.getBaseQualityHeader(), trimmedRead.getTrimmedReadQuality());
return newRecord;
}
示例6: Record
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
Record(final FastqRecord rec)
{
name=rec.getReadName();
sequence=rec.getReadString();
name2=rec.getBaseQualityHeader();
qualities=rec.getBaseQualityString();
}
示例7: qcJoinedReads
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
* Removes pairs of reads where at least one of the pair contains short/long
* reads or a read that contain an 'N', from a fastq file where the reads
* are joined
*
* @param fastqFileIn an interlaced fastq file
* @param leftReadsOut the good left-handed reads
* @param rightReadsOut the good right-handed reads
* @param readLength the expected length of a single read (i.e. half the
* length of one of the joined reads)
* @param format the fastq format (can only be 'illumina' or 'sanger')
* @param writeBadSeqs whether to write the bad reads to a file (bad reads
* file name will start with 'bad_')
*/
public void qcJoinedReads(File fastqFileIn, File leftReadsOut, File rightReadsOut, int readLength, String format, boolean writeBadSeqs)
{
FastqReader fq = new FastqReader(fastqFileIn);
FastqWriterFactory writer = new FastqWriterFactory();
FastqWriter goodLeftSeqs = writer.newWriter(leftReadsOut);
FastqWriter goodRightSeqs = writer.newWriter(rightReadsOut);
FastqWriter badSeqs = getBadSeqFastqWriter(leftReadsOut, writer);
int itCounter = 0;
if (checkFormat(format) == true)
{
//create an interator for each file
for (FastqRecord seqRecord : fq)
{
int seqLength = seqRecord.getReadString().length();
String readString = seqRecord.getReadString();
boolean containsN = readString.toLowerCase().contains("n");
if (seqLength / 2 == readLength && containsN == false)
{
String qual = seqRecord.getBaseQualityString();
String leftRead = readString.substring(0, (seqLength / 2));
String rightRead = readString.substring(seqLength / 2, seqLength);
String leftQual = qual.substring(0, (seqLength / 2));
String rightQual = qual.substring(seqLength / 2, seqLength);
FastqRecord leftSeq = new FastqRecord(seqRecord.getReadHeader() + " 1:N:0:", leftRead, "", leftQual);
FastqRecord rightSeq = new FastqRecord(seqRecord.getReadHeader() + " 2:N:0:", rightRead, "", rightQual);
FastqRecord newLeftSeq = groomRead(leftSeq, format);
FastqRecord newRightSeq = groomRead(rightSeq, format);
goodLeftSeqs.write(newLeftSeq);
goodRightSeqs.write(newRightSeq);
itCounter++;
}
if (writeBadSeqs == true && (seqLength / 2 != readLength || containsN == true))
{
badSeqs.write(seqRecord);
}
}
}
goodLeftSeqs.close();
goodRightSeqs.close();
badSeqs.close();
System.out.println("Completed writing " + itCounter + " good reads");
}
示例8: split
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
*
* @param fastqFile a fastq file of joined left-handed and right-handed reads
* @param leftPairdReads the split left-handed reads
* @param rightPairedReads the split right-handed reads
*/
public void split(File fastqFile, File leftPairdReads, File rightPairedReads)
{
FastqReader fqr = new FastqReader(fastqFile);
FastqWriterFactory writer = new FastqWriterFactory();
FastqWriter leftPairedSeqs = writer.newWriter(leftPairdReads);
FastqWriter rightPairedSeqs = writer.newWriter(rightPairedReads);
Iterator<FastqRecord> it = fqr.iterator();
int peCounter = 0;
//loop thru the interlaced file
while (it.hasNext())
{
FastqRecord fastqRecord = it.next();
//get the read name
String readHeader = fastqRecord.getReadHeader();
//get Sequence
String seq = fastqRecord.getReadString();
String qualString = fastqRecord.getBaseQualityString();
int readlength = seq.length();
int midpoint = readlength/2;
String leftHeader = readHeader.concat(" 1:N:0:");
String rightHeader = readHeader.concat(" 2:N:0:");
String leftRead = seq.substring(0, midpoint);
String rightRead = seq.substring(midpoint, readlength);
String leftQual = qualString.substring(0, midpoint);
String rightQual = qualString.substring(midpoint, readlength);
FastqRecord leftSeq = new FastqRecord(leftHeader, leftRead, "", leftQual);
FastqRecord rightSeq = new FastqRecord(rightHeader, rightRead, "", rightQual);
leftPairedSeqs.write(leftSeq);
rightPairedSeqs.write(rightSeq);
peCounter++;
}
leftPairedSeqs.close();
rightPairedSeqs.close();
System.out.println("Completed spliting " + peCounter + " paired-reads");
}
示例9: run
import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
private void run(FastqReader r,PrintStream out)
{
String s;
long nRec=0L;
r.setValidationStringency(ValidationStringency.LENIENT);
while(r.hasNext())
{
if(++nRec%1E6==0)
{
LOG.info("N-Reads:"+nRec);
}
FastqRecord fastq=r.next();
out.print(FastqConstants.SEQUENCE_HEADER);
out.println(fastq.getReadName());
s=fastq.getReadString();
if((this.only_R2 && nRec%2==1) || (this.only_R1 && nRec%2==0) ) //interleaced
{
out.print(s);
}
else
{
for(int i=s.length()-1;i>=0;i--)
{
out.print(AcidNucleics.complement(s.charAt(i)));
}
}
out.println();
out.print(FastqConstants.QUALITY_HEADER);
s=fastq.getBaseQualityHeader();
if(s!=null) out.print(s);
out.println();
s=fastq.getBaseQualityString();
if((this.only_R2 && nRec%2==1) || (this.only_R1 && nRec%2==0) ) //interleaced
{
out.print(s);
}
else
{
for(int i=s.length()-1;i>=0;i--)
{
out.print(s.charAt(i));
}
}
out.println();
if(out.checkError()) break;
}
out.flush();
LOG.info("Done. N-Reads:"+nRec);
}