当前位置: 首页>>代码示例>>Java>>正文


Java FastqRecord.getBaseQualityString方法代码示例

本文整理汇总了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;
}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:20,代码来源:FastqFindAndTrimTool.java

示例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);

				}
			}
		}
	}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:21,代码来源:FastqUtil.java

示例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;
    }
}
 
开发者ID:bioinform,项目名称:varsim,代码行数:43,代码来源:PBSIMFastqReader.java

示例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);
	}
}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:10,代码来源:FastqWriter.java

示例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;

}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:12,代码来源:FastqReadTrimmer.java

示例6: Record

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
Record(final FastqRecord rec)
{
name=rec.getReadName();
sequence=rec.getReadString();
name2=rec.getBaseQualityHeader();
qualities=rec.getBaseQualityString();
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:8,代码来源:FastqJavascript.java

示例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");
}
 
开发者ID:ethering,项目名称:GenomeHelper,代码行数:64,代码来源:FastqQC.java

示例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");
}
 
开发者ID:ethering,项目名称:GenomeHelper,代码行数:49,代码来源:FastqJoiner.java

示例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);
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:55,代码来源:FastqRevComp.java


注:本文中的htsjdk.samtools.fastq.FastqRecord.getBaseQualityString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。