• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SAMTag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: callElPrep

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
public int callElPrep(String input, String output, String rg, int threads, 
        SAMRecordIterator SAMit,
        SAMFileHeader header, String dictFile, boolean updateRG, boolean keepDups, String RGID) throws InterruptedException, QualityException {
    
    SAMRecord sam;
    SAMFileWriterFactory factory = new SAMFileWriterFactory();
    SAMFileWriter Swriter = factory.makeSAMWriter(header, true, new File(input));
    
    int reads = 0;
    while(SAMit.hasNext()) {
        sam = SAMit.next();
        if(updateRG)
            sam.setAttribute(SAMTag.RG.name(), RGID);
        Swriter.addAlignment(sam);
        reads++;
    }
    Swriter.close();
    
    String customArgs = HalvadeConf.getCustomArgs(context.getConfiguration(), "elprep", "");  
    String[] command = CommandGenerator.elPrep(bin, input, output, threads, true, rg, null, !keepDups, customArgs);
    long estimatedTime = runProcessAndWait("elPrep", command);
    if(context != null)
        context.getCounter(HalvadeCounters.TIME_ELPREP).increment(estimatedTime);
    
    return reads;
}
 
开发者ID:biointec,项目名称:halvade,代码行数:27,代码来源:PreprocessingTools.java


示例2: FastqGATKRead

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Creates a GATKRead from a FastqRecord and a header.
 *
 * @param header the header for the record.
 * @param record the record to use as GATKRead.
 */
public FastqGATKRead(final SAMFileHeader header, final FastqRecord record) {
    super(new SAMRecord(header));
    Utils.nonNull(record, "null record");
    // update the record with the read name information
    FastqReadNameEncoding.updateReadFromReadName(this, record.getReadName());
    // set the bases and the qualities
    this.setBases(record.getReadBases());
    this.setBaseQualities(record.getBaseQualities());
    // add the comments in the quality header to the comment if present
    final String baseQualHeader = record.getBaseQualityHeader();
    if (baseQualHeader != null) {
        // the default tag in the specs is CO
        this.setAttribute(SAMTag.CO.toString(), baseQualHeader);
    }
    this.setIsUnmapped();
    if (this.isPaired()) {
        this.setMateIsUnmapped();
    }
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:26,代码来源:FastqGATKRead.java


示例3: test

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Override
public boolean test( final GATKRead read ) {
    final SAMReadGroupRecord readGroup = ReadUtils.getSAMReadGroupRecord(read, samHeader);
    if ( readGroup == null ) {
        return true;
    }

    for (final String attributeType : blacklistEntries.keySet()) {

        final String attribute;
        if (SAMReadGroupRecord.READ_GROUP_ID_TAG.equals(attributeType) || SAMTag.RG.name().equals(attributeType)) {
            attribute = readGroup.getId();
        } else {
            attribute = readGroup.getAttribute(attributeType);
        }
        if (attribute != null && blacklistEntries.get(attributeType).contains(attribute)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:ReadGroupBlackListReadFilter.java


示例4: writeHaplotype

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Write out a representation of this haplotype as a read
 *
 * @param haplotype a haplotype to write out, must not be null
 * @param paddedRefLoc the reference location, must not be null
 * @param isAmongBestHaplotypes true if among the best haplotypes, false if it was just one possible haplotype
 */
private void writeHaplotype(final Haplotype haplotype,
                            final Locatable paddedRefLoc,
                            final boolean isAmongBestHaplotypes) {
    Utils.nonNull(haplotype, "haplotype cannot be null");
    Utils.nonNull(paddedRefLoc, "paddedRefLoc cannot be null");

    final SAMRecord record = new SAMRecord(output.getBAMOutputHeader());
    record.setReadBases(haplotype.getBases());
    record.setAlignmentStart(paddedRefLoc.getStart() + haplotype.getAlignmentStartHapwrtRef());
    // Use a base quality value "!" for it's display value (quality value is not meaningful)
    record.setBaseQualities(Utils.dupBytes((byte) '!', haplotype.getBases().length));
    record.setCigar(AlignmentUtils.consolidateCigar(haplotype.getCigar()));
    record.setMappingQuality(isAmongBestHaplotypes ? bestHaplotypeMQ : otherMQ);
    record.setReadName(output.getHaplotypeSampleTag() + uniqueNameCounter++);
    record.setAttribute(output.getHaplotypeSampleTag(), haplotype.hashCode());
    record.setReadUnmappedFlag(false);
    record.setReferenceIndex(output.getBAMOutputHeader().getSequenceIndex(paddedRefLoc.getContig()));
    record.setAttribute(SAMTag.RG.toString(), output.getHaplotypeReadGroupID());
    record.setFlags(SAMFlag.READ_REVERSE_STRAND.intValue());

    output.add(new SAMRecordToGATKReadAdapter(record));
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:30,代码来源:HaplotypeBAMWriter.java


示例5: clearReadAlignment

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Returns input read with alignment-related info cleared
 */
private static GATKRead clearReadAlignment(final GATKRead read, final SAMFileHeader header) {
    final GATKRead newRead = new SAMRecordToGATKReadAdapter(new SAMRecord(header));
    newRead.setName(read.getName());
    newRead.setBases(read.getBases());
    newRead.setBaseQualities(read.getBaseQualities());
    if (read.isReverseStrand()) {
        SequenceUtil.reverseComplement(newRead.getBases());
        SequenceUtil.reverseQualities(newRead.getBaseQualities());
    }
    newRead.setIsUnmapped();
    newRead.setIsPaired(read.isPaired());
    if (read.isPaired()) {
        newRead.setMateIsUnmapped();
        if (read.isFirstOfPair()) {
            newRead.setIsFirstOfPair();
        } else if (read.isSecondOfPair()) {
            newRead.setIsSecondOfPair();
        }
    }
    final String readGroup = read.getReadGroup();
    if (readGroup != null) {
        newRead.setAttribute(SAMTag.RG.name(), readGroup);
    }
    return newRead;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:29,代码来源:PSFilter.java


示例6: testUsingOriginalQualities

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Test
public void testUsingOriginalQualities() throws Exception {
    final MeanQualityByCycleSpark.HistogramGenerator hg = new MeanQualityByCycleSpark.HistogramGenerator(true);
    Assert.assertEquals(hg.useOriginalQualities, true);

    GATKRead read1 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{50, 50}, "2M");
    hg.addRead(read1);
    assertEqualsLongArray(hg.firstReadCountsByCycle, new long[0]);
    assertEqualsDoubleArray(hg.firstReadTotalsByCycle, new double[0], 1e-05);
    assertEqualsLongArray(hg.secondReadCountsByCycle, new long[0]);
    assertEqualsDoubleArray(hg.secondReadTotalsByCycle, new double[0], 1e-05);

    GATKRead read2 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{50, 50}, "2M");
    read2.setAttribute(SAMTag.OQ.name(), SAMUtils.phredToFastq(new byte[]{30, 40}));
    hg.addRead(read2);

    assertEqualsLongArray(hg.firstReadCountsByCycle, new long[]{0, 1, 1});
    assertEqualsDoubleArray(hg.firstReadTotalsByCycle, new double[]{0, 30, 40}, 1e-05);
    assertEqualsLongArray(hg.secondReadCountsByCycle, new long[]{0, 0, 0});
    assertEqualsDoubleArray(hg.secondReadTotalsByCycle, new double[]{0, 0, 0}, 1e-05);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:MeanQualityHistogramGeneratorUnitTest.java


示例7: reduce

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Override
protected void reduce(ChromosomeRegion key, Iterable<SAMRecordWritable> values, Context context) throws IOException, InterruptedException {
    Iterator<SAMRecordWritable> it = values.iterator();
    SAMRecord sam = null;
    while(it.hasNext()) {
        sam = it.next().get();
        if(!inputIsBam  || updateRG) {
            sam.setAttribute(SAMTag.RG.name(), RGID);
        }
        samWritable.set(sam);
        recordWriter.write(outKey, samWritable);
                
    }
}
 
开发者ID:biointec,项目名称:halvade,代码行数:15,代码来源:BamMergeReducer.java


示例8: streamElPrep

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
public int streamElPrep(Reducer.Context context, String output, String rg, 
            int threads, SAMRecordIterator SAMit, 
            SAMFileHeader header, String dictFile, boolean updateRG, boolean keepDups, String RGID) throws InterruptedException, IOException, QualityException {
        long startTime = System.currentTimeMillis();
        String customArgs = HalvadeConf.getCustomArgs(context.getConfiguration(), "elprep", "");  
        String[] command = CommandGenerator.elPrep(bin, "/dev/stdin", output, threads, true, rg, null, !keepDups, customArgs);
//        runProcessAndWait(command);
        ProcessBuilderWrapper builder = new ProcessBuilderWrapper(command, null);
        builder.startProcess(true);        
        BufferedWriter localWriter = builder.getSTDINWriter();
        
        // write header
        final StringWriter headerTextBuffer = new StringWriter();
        new SAMTextHeaderCodec().encode(headerTextBuffer, header);
        final String headerText = headerTextBuffer.toString();
        localWriter.write(headerText, 0, headerText.length());
        
        
        SAMRecord sam;
        int reads = 0;
        while(SAMit.hasNext()) {
            sam = SAMit.next();
            if(updateRG)
                sam.setAttribute(SAMTag.RG.name(), RGID);
            String samString = sam.getSAMString();
            localWriter.write(samString, 0, samString.length());
            reads++;
        }
        localWriter.flush();
        localWriter.close();
                
        int error = builder.waitForCompletion();
        if(error != 0)
            throw new ProcessException("elPrep", error);
        long estimatedTime = System.currentTimeMillis() - startTime;
        Logger.DEBUG("estimated time: " + estimatedTime / 1000);
        if(context != null)
            context.getCounter(HalvadeCounters.TIME_ELPREP).increment(estimatedTime);
        return reads;
    }
 
开发者ID:biointec,项目名称:halvade,代码行数:41,代码来源:PreprocessingTools.java


示例9: addRead

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Override
public void addRead(final GATKRead read) {
    // adding the raw barcode information if found
    String readName = RTReadUtils.getReadNameWithIlluminaBarcode(read);
    // adding the pair information
    if (read.isPaired()) {
        readName += (read.isFirstOfPair())
                ? FastqConstants.FIRST_OF_PAIR : FastqConstants.SECOND_OF_PAIR;
    }
    writer.write(new FastqRecord(readName,
            read.getBasesString(),
            read.getAttributeAsString(SAMTag.CO.name()),
            ReadUtils.getBaseQualityString(read)));
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:15,代码来源:FastqGATKWriter.java


示例10: test

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Override
public boolean test(final GATKRead read) {
    metric.TOTAL++;
    // trimming function modify in place the read
    final boolean pass = delegate.test(read);
    // update the metrics
    if (pass) {
        metric.PASSED++;
    } else {
        // if it does not pass, add a FT tag with the name of the filter
        read.setAttribute(SAMTag.FT.name(), metric.FILTER);
    }
    return pass;
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:15,代码来源:TrimAndFilterPipeline.java


示例11: fastqRecordDataProvider

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@DataProvider(name = "fastqRecordData")
public Iterator<Object[]> fastqRecordDataProvider() {
    final String baseQualities = "FFGCHI5";
    final String bases = "ACTGTTAG";
    final GATKRead baseRecord = ArtificialReadUtils
            .createArtificialUnmappedRead(null,
                    new byte[] {'A', 'C', 'T', 'G', 'T', 'T', 'A', 'G'},
                    new byte[] {37, 37, 38, 34, 39, 40, 20});
    baseRecord.setName("baseRecord");
    final List<Object[]> data = new ArrayList<>();
    // simple case test
    data.add(new Object[] {new FastqRecord(baseRecord.getName(), bases, null, baseQualities),
            baseRecord.deepCopy()});
    // case with comment information
    baseRecord.setAttribute(SAMTag.CO.name(), "quality comment");
    data.add(new Object[] {
            new FastqRecord(baseRecord.getName(), bases, "quality comment", baseQualities),
            baseRecord.deepCopy()});
    // case with a read name with pair-end information
    baseRecord.setIsSecondOfPair();
    baseRecord.setIsUnmapped();
    data.add(new Object[] {
            new FastqRecord(baseRecord.getName() + "/2", bases, "quality comment",
                    baseQualities),
            baseRecord.deepCopy()});
    // case with read name as CASAVA format
    baseRecord.setName("baseRecord");
    baseRecord.setAttribute("BC", "ATCG");
    data.add(new Object[] {
            new FastqRecord("baseRecord 2:N:3:ATCG", bases, "quality comment", baseQualities),
            baseRecord.deepCopy()});
    // case with PF flag
    baseRecord.setFailsVendorQualityCheck(true);
    data.add(new Object[] {
            new FastqRecord("baseRecord 2:Y:3:ATCG", bases, "quality comment", baseQualities),
            baseRecord.deepCopy()});
    return data.iterator();
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:39,代码来源:FastqGATKReadUnitTest.java


示例12: compare

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
public int compare(final SAMRecord rec1, final SAMRecord rec2) {
    final Integer hi1 = rec1.getIntegerAttribute(SAMTag.HI.name());
    final Integer hi2 = rec2.getIntegerAttribute(SAMTag.HI.name());
    if (hi1 == null) {
        if (hi2 == null) return 0;
        else return 1;
    } else if (hi2 == null) {
        return -1;
    } else {
        return hi1.compareTo(hi2);
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:13,代码来源:HitsForInsert.java


示例13: writeReads

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Helper function that writes reads from iterator it into writer out, updating each SAMRecord along the way
 * according to the newOrder mapping from dictionary index -> index.  Name is used for printing only.
 */
private void writeReads(final SAMFileWriter out,
                        final SAMRecordIterator it,
                        final Map<Integer, Integer> newOrder,
                        final String name) {
    long counter = 0;
    log.info("  Processing " + name);

    while (it.hasNext()) {
        counter++;
        final SAMRecord read = it.next();
        final int oldRefIndex = read.getReferenceIndex();
        final int oldMateIndex = read.getMateReferenceIndex();
        final int newRefIndex = newOrderIndex(read, oldRefIndex, newOrder);

        read.setHeader(out.getFileHeader());
        read.setReferenceIndex(newRefIndex);

        final int newMateIndex = newOrderIndex(read, oldMateIndex, newOrder);
        if (oldMateIndex != -1 && newMateIndex == -1) { // becoming unmapped
            read.setMateAlignmentStart(0);
            read.setMateUnmappedFlag(true);
            read.setAttribute(SAMTag.MC.name(), null);      // Set the Mate Cigar String to null
        }
        read.setMateReferenceIndex(newMateIndex);

        out.addAlignment(read);
    }

    it.close();
    log.info("Wrote " + counter + " reads");
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:36,代码来源:ReorderSam.java


示例14: getOutieMode

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Calculates the mode for outward-facing pairs, using the first SAMPLE_FOR_MODE
 * outward-facing pairs found in INPUT
 */
private double getOutieMode() {

    int samplePerFile = SAMPLE_FOR_MODE / INPUT.size();

    Histogram<Integer> histo = new Histogram<Integer>();

    for (File f : INPUT) {
        SamReader reader = SamReaderFactory.makeDefault().open(f);
        int sampled = 0;
        for (Iterator<SAMRecord> it = reader.iterator(); it.hasNext() && sampled < samplePerFile; ) {
            SAMRecord sam = it.next();
            if (!sam.getFirstOfPairFlag()) {
                continue;
            }
            // If we get here we've hit the end of the aligned reads
            if (sam.getReadUnmappedFlag() && sam.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
                break;
            } else if (sam.getReadUnmappedFlag() || sam.getMateUnmappedFlag()) {
                continue;
            } else if ((sam.getAttribute(SAMTag.MQ.name()) == null ||
                    sam.getIntegerAttribute(SAMTag.MQ.name()) >= MINIMUM_MAPPING_QUALITY) &&
                    sam.getMappingQuality() >= MINIMUM_MAPPING_QUALITY &&
                    sam.getMateNegativeStrandFlag() != sam.getReadNegativeStrandFlag() &&
                    sam.getMateReferenceIndex().equals(sam.getReferenceIndex()) &&
                    SamPairUtil.getPairOrientation(sam) == PairOrientation.RF) {
                histo.increment(Math.abs(sam.getInferredInsertSize()));
                sampled++;
            }
        }
        CloserUtil.close(reader);
    }

    return histo.size() > 0 ? histo.getMode() : 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:39,代码来源:CollectJumpingLibraryMetrics.java


示例15: getPlatformUnit

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
private String getPlatformUnit( final GATKRead read ) {
    final String pu_attr = read.getAttributeAsString(SAMTag.PU.name());
    if ( pu_attr != null ) {
        return pu_attr;
    }

    return ReadUtils.getPlatformUnit(read, samHeader);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:9,代码来源:PlatformUnitReadFilter.java


示例16: compare

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Override
public int compare(final SAMRecord rec1, final SAMRecord rec2) {
    final Integer hi1 = rec1.getIntegerAttribute(SAMTag.HI.name());
    final Integer hi2 = rec2.getIntegerAttribute(SAMTag.HI.name());
    if (hi1 == null) {
        if (hi2 == null) return 0;
        else return 1;
    } else if (hi2 == null) {
        return -1;
    } else {
        return hi1.compareTo(hi2);
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:14,代码来源:HitsForInsert.java


示例17: testAccumulators

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
@Test(groups = "spark")
public void testAccumulators() throws Exception {
    final long[] qs= new long[128];
    final long[] oqs= new long[128];

    final Counts counts = new Counts(false);
    final long[] initQs = counts.getQualCounts();
    final long[] initOQs = counts.getOrigQualCounts();
    Assert.assertEquals(initQs, qs);
    Assert.assertEquals(initOQs, oqs);

    final GATKRead read1 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{50, 50}, "2M");
    read1.setAttribute(SAMTag.OQ.name(), SAMUtils.phredToFastq(new byte[]{30, 40}));
    counts.addRead(read1);

    qs[50]+=2;//there are two bases in the read with a quality score of 50
    oqs[30]+=1;
    oqs[40]+=1;
    final long[] oneQs = counts.getQualCounts();
    final long[] oneOQs = counts.getOrigQualCounts();
    Assert.assertEquals(oneQs, qs);
    Assert.assertEquals(oneOQs, oqs);

    final Counts counts2 = new Counts(false);

    final GATKRead read2 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{51, 51}, "2M");
    read2.setAttribute(SAMTag.OQ.name(), SAMUtils.phredToFastq(new byte[]{31, 41}));
    counts2.addRead(read2);

    counts.merge(counts2);
    qs[51]+=2;//there are two bases in the read with a quality score of 51
    oqs[31]+=1;  //new read OQ
    oqs[41]+=1;  //new read OQ
    final long[] mergedQs = counts.getQualCounts();
    final long[] mergedOQs = counts.getOrigQualCounts();
    Assert.assertEquals(mergedQs, qs);
    Assert.assertEquals(mergedOQs, oqs);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:39,代码来源:QualityScoreDistributionSparkIntegrationTest.java


示例18: realignerCore

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
private void realignerCore(AlternateConsensus bestConsensus, ArrayList<GaeaAlignedSamRecord> reads, byte[] ref,
		GenomeLocation location, long totalRawMismatchQuality, int leftMostIndex) {
	double improvement = (bestConsensus == null ? -1
			: ((double) (totalRawMismatchQuality - bestConsensus.getMismatch())) / 10.0);

	double threshold = 5.0;
	if (improvement < threshold)
		return;
	
	int posOnRef = bestConsensus.getPositionOnReference();
	Cigar newCigar = AlignmentUtil.leftAlignIndel(bestConsensus.getCigar(), ref, bestConsensus.getSequence(),
			posOnRef, posOnRef);
	bestConsensus.setCigar(newCigar);

	GaeaAlignedSamRecord alignRead = null;
	for (Pair<Integer, Integer> pair : bestConsensus.getReadIndexes()) {
		alignRead = reads.get(pair.first);
		if (!consensusEngine.updateRead(bestConsensus.getCigar(), posOnRef, pair.second, alignRead, leftMostIndex))
			return;
	}

	boolean condi = consensusEngine.needRealignment(reads, ref, leftMostIndex);
	
	if (condi) {
		for (Pair<Integer, Integer> indexPair : bestConsensus.getReadIndexes()) {
			alignRead = reads.get(indexPair.first);
			if (alignRead.statusFinalize()) {
				GaeaSamRecord read = alignRead.getRead();

				if (read.getMappingQuality() != 255)
					read.setMappingQuality(Math.min(alignRead.getRead().getMappingQuality() + 10, 254));

				int neededBasesToLeft = leftMostIndex - read.getAlignmentStart();
				int neededBasesToRight = read.getAlignmentEnd() - leftMostIndex - ref.length + 1;
				int neededBases = Math.max(neededBasesToLeft, neededBasesToRight);
				if (neededBases > 0) {
					int padLeft = Math.max(leftMostIndex - neededBases, 1);
					int padRight = Math.min(leftMostIndex + ref.length + neededBases,parser.getContigInfo(location.getContig()).getSequenceLength()-1);
					ref = chrInfo.getBaseSequence(padLeft, padRight).getBytes();
					leftMostIndex = padLeft;
				}

				try {
					if (read.getAttribute(SAMTag.NM.name()) != null)
						read.setAttribute(SAMTag.NM.name(),
								SequenceUtil.calculateSamNmTag(read, ref, leftMostIndex - 1));
					if (read.getAttribute(SAMTag.UQ.name()) != null)
						read.setAttribute(SAMTag.UQ.name(),
								SequenceUtil.sumQualitiesOfMismatches(read, ref, leftMostIndex - 1));
				} catch (Exception e) {
					// ignore it
					// throw new RuntimeException(e.toString());
				}
				if (read.getAttribute(SAMTag.MD.name()) != null)
					read.setAttribute(SAMTag.MD.name(), null);
			}
		}
	}
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:60,代码来源:IndelRealigner.java


示例19: setMateInfo

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Write the mate info for two SAMRecords
 */
public static void setMateInfo(final GaeaSamRecord rec1,
		final GaeaSamRecord rec2, final SAMFileHeader header) {
	// If neither read is unmapped just set their mate info
	if (!rec1.getReadUnmappedFlag() && !rec2.getReadUnmappedFlag()) {

		rec1.setMateReferenceIndex(rec2.getReferenceIndex());
		rec1.setMateAlignmentStart(rec2.getAlignmentStart());
		rec1.setMateNegativeStrandFlag(rec2.getReadNegativeStrandFlag());
		rec1.setMateUnmappedFlag(false);
		rec1.setAttribute(SAMTag.MQ.name(), rec2.getMappingQuality());

		rec2.setMateReferenceIndex(rec1.getReferenceIndex());
		rec2.setMateAlignmentStart(rec1.getAlignmentStart());
		rec2.setMateNegativeStrandFlag(rec1.getReadNegativeStrandFlag());
		rec2.setMateUnmappedFlag(false);
		rec2.setAttribute(SAMTag.MQ.name(), rec1.getMappingQuality());
	}
	// Else if they're both unmapped set that straight
	else if (rec1.getReadUnmappedFlag() && rec2.getReadUnmappedFlag()) {
		rec1.setReferenceIndex(GaeaSamRecord.NO_ALIGNMENT_REFERENCE_INDEX);
		rec1.setAlignmentStart(GaeaSamRecord.NO_ALIGNMENT_START);
		rec1.setMateReferenceIndex(GaeaSamRecord.NO_ALIGNMENT_REFERENCE_INDEX);
		rec1.setMateAlignmentStart(GaeaSamRecord.NO_ALIGNMENT_START);
		rec1.setMateNegativeStrandFlag(rec2.getReadNegativeStrandFlag());
		rec1.setMateUnmappedFlag(true);
		rec1.setAttribute(SAMTag.MQ.name(), null);
		rec1.setInferredInsertSize(0);

		rec2.setReferenceIndex(GaeaSamRecord.NO_ALIGNMENT_REFERENCE_INDEX);
		rec2.setAlignmentStart(GaeaSamRecord.NO_ALIGNMENT_START);
		rec2.setMateReferenceIndex(GaeaSamRecord.NO_ALIGNMENT_REFERENCE_INDEX);
		rec2.setMateAlignmentStart(GaeaSamRecord.NO_ALIGNMENT_START);
		rec2.setMateNegativeStrandFlag(rec1.getReadNegativeStrandFlag());
		rec2.setMateUnmappedFlag(true);
		rec2.setAttribute(SAMTag.MQ.name(), null);
		rec2.setInferredInsertSize(0);
	}
	// And if only one is mapped copy it's coordinate information to the
	// mate
	else {
		final GaeaSamRecord mapped = rec1.getReadUnmappedFlag() ? rec2
				: rec1;
		final GaeaSamRecord unmapped = rec1.getReadUnmappedFlag() ? rec1
				: rec2;
		unmapped.setReferenceIndex(mapped.getReferenceIndex());
		unmapped.setAlignmentStart(mapped.getAlignmentStart());

		mapped.setMateReferenceIndex(unmapped.getReferenceIndex());
		mapped.setMateAlignmentStart(unmapped.getAlignmentStart());
		mapped.setMateNegativeStrandFlag(unmapped
				.getReadNegativeStrandFlag());
		mapped.setMateUnmappedFlag(true);
		mapped.setInferredInsertSize(0);

		unmapped.setMateReferenceIndex(mapped.getReferenceIndex());
		unmapped.setMateAlignmentStart(mapped.getAlignmentStart());
		unmapped.setMateNegativeStrandFlag(mapped
				.getReadNegativeStrandFlag());
		unmapped.setMateUnmappedFlag(false);
		unmapped.setInferredInsertSize(0);
	}

	final int insertSize = GaeaSamPairUtil.computeInsertSize(rec1, rec2);
	rec1.setInferredInsertSize(insertSize);
	rec2.setInferredInsertSize(-insertSize);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:70,代码来源:GaeaSamPairUtil.java


示例20: createSamRecord

import htsjdk.samtools.SAMTag; //导入依赖的package包/类
/**
 * Creates a new SAM record from the basecall data
 */
private SAMRecord createSamRecord(final ReadData readData, final String readName, final boolean isPf, final boolean firstOfPair,
                                  final String unmatchedBarcode,
                                  final List<String> molecularIndexes, final List<String> molecularIndexQualities) {
    final SAMRecord sam = new SAMRecord(null);
    sam.setReadName(readName);
    sam.setReadBases(readData.getBases());
    sam.setBaseQualities(readData.getQualities());

    // Flag values
    sam.setReadPairedFlag(isPairedEnd);
    sam.setReadUnmappedFlag(true);
    sam.setReadFailsVendorQualityCheckFlag(!isPf);
    if (isPairedEnd) {
        sam.setMateUnmappedFlag(true);
        sam.setFirstOfPairFlag(firstOfPair);
        sam.setSecondOfPairFlag(!firstOfPair);
    }

    if (filters.filterOut(sam)) {
        sam.setAttribute(ReservedTagConstants.XN, 1);
    }

    if (this.readGroupId != null) {
        sam.setAttribute(SAMTag.RG.name(), readGroupId);
    }

    // If it's a barcoded run and the read isn't assigned to a barcode, then add the barcode
    // that was read as an optional tag
    if (unmatchedBarcode != null) {
        sam.setAttribute(SAMTag.BC.name(), unmatchedBarcode);
    }

    if (!molecularIndexes.isEmpty()) {
        if (!this.molecularIndexTag.isEmpty()) {
            sam.setAttribute(this.molecularIndexTag, String.join(molecularIndexDelimiter, molecularIndexes));
        }
        if (!this.molecularIndexQualityTag.isEmpty()) {
            sam.setAttribute(this.molecularIndexQualityTag, String.join(molecularIndexDelimiter, molecularIndexQualities));
        }
        if (!this.tagPerMolecularIndex.isEmpty()) {
            if (tagPerMolecularIndex.size() != molecularIndexes.size()) {
                throw new PicardException("Found " + molecularIndexes.size() + " molecular indexes but only " + tagPerMolecularIndex.size() + " SAM tags given.");
            }
            for (int i = 0; i < this.tagPerMolecularIndex.size(); i++) {
                sam.setAttribute(this.tagPerMolecularIndex.get(i), molecularIndexes.get(i));
            }
        }
    }

    return sam;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:55,代码来源:ClusterDataToSamConverter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProcessingInstruction类代码示例发布时间:2022-05-22
下一篇:
Java UnflaggedOption类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap