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


Java FastqRecord.getReadHeader方法代码示例

本文整理汇总了Java中htsjdk.samtools.fastq.FastqRecord.getReadHeader方法的典型用法代码示例。如果您正苦于以下问题:Java FastqRecord.getReadHeader方法的具体用法?Java FastqRecord.getReadHeader怎么用?Java FastqRecord.getReadHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.samtools.fastq.FastqRecord的用法示例。


在下文中一共展示了FastqRecord.getReadHeader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSamRecord

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
private SAMRecord createSamRecord(final SAMFileHeader header, final String baseName, final FastqRecord frec, final boolean paired) {
    final SAMRecord srec = new SAMRecord(header);
    srec.setReadName(baseName);
    srec.setReadString(frec.getReadString());
    srec.setReadUnmappedFlag(true);
    srec.setAttribute(ReservedTagConstants.READ_GROUP_ID, READ_GROUP_NAME);
    final byte[] quals = StringUtil.stringToBytes(frec.getBaseQualityString());
    convertQuality(quals, QUALITY_FORMAT);
    for (final byte qual : quals) {
        final int uQual = qual & 0xff;
        if (uQual < MIN_Q || uQual > MAX_Q) {
            throw new PicardException("Base quality " + uQual + " is not in the range " + MIN_Q + ".." +
            MAX_Q + " for read " + frec.getReadHeader());
        }
    }
    srec.setBaseQualities(quals);

    if (paired) {
        srec.setReadPairedFlag(true);
        srec.setMateUnmappedFlag(true);
    }
    return srec ;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:24,代码来源:FastqToSam.java

示例2: 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

示例3: 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

示例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: verifyReadNamesCanBeHandledByDedup

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
public static void verifyReadNamesCanBeHandledByDedup(File inputFastqOne, File inputFastqTwo) {
	long start = System.currentTimeMillis();
	Set<Character> uniqueCharacters = new HashSet<Character>();
	int fastqEntryIndex = 0;
	try (FastqReader fastQOneReader = new FastqReader(inputFastqOne)) {
		try (FastqReader fastQTwoReader = new FastqReader(inputFastqTwo)) {
			while (fastQOneReader.hasNext() && fastQTwoReader.hasNext()) {

				FastqRecord oneRecord = fastQOneReader.next();
				FastqRecord twoRecord = fastQTwoReader.next();
				String readNameOne = oneRecord.getReadHeader();
				String readNameTwo = twoRecord.getReadHeader();

				String uniqueReadNameOne = IlluminaFastQReadNameUtil.getUniqueIdForReadHeader(readNameOne);
				String uniqueReadNameTwo = IlluminaFastQReadNameUtil.getUniqueIdForReadHeader(readNameTwo);
				if (!uniqueReadNameOne.equals(uniqueReadNameTwo)) {
					int lineNumber = (fastqEntryIndex * 4) + 1;
					throw new IllegalStateException("The read names[" + readNameOne + "][" + readNameTwo + "] found at line[" + lineNumber + "] in fastqOne[" + inputFastqOne.getAbsolutePath()
							+ "] and fastqTwo[" + inputFastqTwo.getAbsolutePath() + "] respectively are not valid Illumina read names.");
				}

				for (int i = 0; i < uniqueReadNameOne.length(); i++) {
					uniqueCharacters.add(uniqueReadNameOne.charAt(i));
				}

				fastqEntryIndex++;
			}
		}
	}
	long end = System.currentTimeMillis();
	logger.info("Verified that the read names can be handled by dedup in " + DateUtil.convertMillisecondsToHHMMSS(end - start) + "(HH:MM:SS).");
}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:33,代码来源:PrimerReadExtensionAndPcrDuplicateIdentification.java

示例6: 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

示例7: writeRecords

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
 *
 * @param fastqReader a FastqReader object
 * @param out - the output fastq reads
 * @param mappedReads a HashSet of mapped reads
 */
public static void writeRecords(FastqReader fastqReader, FastqWriter out, HashSet<String> mappedReads) {
    while (fastqReader.hasNext()) {
        FastqRecord record = fastqReader.next();
        String readName = record.getReadHeader();
        int hashIndex = readName.indexOf(" ");
        readName = readName.substring(0, hashIndex);
        if (mappedReads.contains(readName)) {
            out.write(record);
        }
    }
    out.close();
}
 
开发者ID:ethering,项目名称:GenomeHelper,代码行数:19,代码来源:FastqParser.java

示例8: getPairedFastqSeqsFromHashSet

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
 * Extract paired-end fastq sequences from a list of sequence names
 *
 * @param list a HashSet of read names
 * @param fastqLeft all left-handed reads
 * @param fastqRight all right-handed reads
 * @param fastqLeftOut the left-handed reads in the list
 * @param fastqRightOut the right-handed reads in the list
 * @throws FileNotFoundException
 * @throws IOException
 */
public void getPairedFastqSeqsFromHashSet(HashSet list, File fastqLeft, File fastqRight,
        File fastqLeftOut, File fastqRightOut) throws FileNotFoundException, IOException {
    final FastqReader readerLeft = new FastqReader(fastqLeft);
    final FastqReader readerRight = new FastqReader(fastqRight);

    FastqWriterFactory writer = new FastqWriterFactory();
    FastqWriter outLeft = writer.newWriter(fastqLeftOut);
    FastqWriter outRight = writer.newWriter(fastqRightOut);
    int recordsfound = 0;

    while (readerLeft.hasNext()) {
        FastqRecord recordLeft = readerLeft.next();
        FastqRecord recordRight = readerRight.next();
        String leftRead = recordLeft.getReadHeader();

        int hashIndex = leftRead.indexOf(" ");
        leftRead = leftRead.substring(0, hashIndex);
        if (list.contains(leftRead)) {
            recordsfound++;
            outLeft.write(recordLeft);
            outRight.write(recordRight);
        }
    }
    System.out.println("Processed " + list.size() + " , found " + recordsfound);

}
 
开发者ID:ethering,项目名称:GenomeHelper,代码行数:38,代码来源:FastqParser.java

示例9: 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

示例10: 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

示例11: fastqToFastaSeq

import htsjdk.samtools.fastq.FastqRecord; //导入方法依赖的package包/类
/**
 * Takes a net.sf.picard.fastq.FastqRecord and changes it into a
 * org.biojava3.data.sequence.FastqSequence
 *
 * @param record the FastqRecord to change
 * @return a FastaSequence object
 * @throws IOException
 */
public FastaSequence fastqToFastaSeq(FastqRecord record) throws IOException {
    String readName = record.getReadHeader();
    String seq = record.getReadString();
    FastaSequence fasta = new FastaSequence(readName, seq);
    return fasta;
}
 
开发者ID:ethering,项目名称:GenomeHelper,代码行数:15,代码来源:FastqParser.java


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