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


Java SAMReadGroupRecord类代码示例

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


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

示例1: transfer

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
public static SAMFileHeader transfer(SamHeaderInfo samHeaderInfo){
    SAMFileHeader header = new SAMFileHeader();
    // read groups
    List<ReadGroupInfo> readGroupInfoList = CollectionConverter.asJavaList(samHeaderInfo.getReadGroupInfos());
    List<SAMReadGroupRecord> samReadGroupRecords = readGroupInfoList.stream()
            .map(SAMReadGroupRecordTransfer::transfer)
            .collect(Collectors.toList());
    header.setReadGroups(samReadGroupRecords);
    // Sequence records
    // TODO 获取id的方法不通用 fix me
    int contigCount = samHeaderInfo.getRefContigInfo().getContigIds().size();
    for(int id = 0; id < contigCount; id ++) {
        header.addSequence(new SAMSequenceRecord(
                samHeaderInfo.getRefContigInfo().getName(id),
                samHeaderInfo.getRefContigInfo().getLength(id)));
    }
    if(samHeaderInfo.sorted()) {
        header.setAttribute("SO", "coordinate");
    }
    return header;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:22,代码来源:SAMHeaderTransfer.java

示例2: getReadGroup

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * Get the GATKSAMReadGroupRecord of this read
 * @return a non-null GATKSAMReadGroupRecord
 */
@Override
public GATKSAMReadGroupRecord getReadGroup() {
    if ( ! retrievedReadGroup ) {
        final SAMReadGroupRecord rg = super.getReadGroup();

        // three cases: rg may be null (no rg, rg may already be a GATKSAMReadGroupRecord, or it may be
        // a regular SAMReadGroupRecord in which case we have to make it a GATKSAMReadGroupRecord
        if ( rg == null )
            mReadGroup = null;
        else if ( rg instanceof GATKSAMReadGroupRecord )
            mReadGroup = (GATKSAMReadGroupRecord)rg;
        else
            mReadGroup = new GATKSAMReadGroupRecord(rg);

        retrievedReadGroup = true;
    }
    return mReadGroup;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:23,代码来源:GATKSAMRecord.java

示例3: createEnumeratedReadGroups

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * setup read groups for the specified read groups and sample names
 *
 * @param header       the header to set
 * @param readGroupIDs the read group ID tags
 * @param sampleNames  the sample names
 * @return the adjusted SAMFileHeader
 */
public static SAMFileHeader createEnumeratedReadGroups(SAMFileHeader header, List<String> readGroupIDs, List<String> sampleNames) {
    if (readGroupIDs.size() != sampleNames.size()) {
        throw new ReviewedGATKException("read group count and sample name count must be the same");
    }

    List<SAMReadGroupRecord> readGroups = new ArrayList<SAMReadGroupRecord>();

    int x = 0;
    for (; x < readGroupIDs.size(); x++) {
        SAMReadGroupRecord rec = new SAMReadGroupRecord(readGroupIDs.get(x));
        rec.setSample(sampleNames.get(x));
        readGroups.add(rec);
    }
    header.setReadGroups(readGroups);
    return header;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:25,代码来源:ArtificialSAMUtils.java

示例4: getStaticDataInstance

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
public static StaticData getStaticDataInstance(RefContigInfo refContigInfo,
                                               boolean useGVCF,
                                               SamHeaderInfo samHeaderInfo,
                                               VcfHeaderInfo vcfHeaderInfo) {
    StaticData data = new StaticData();
    SAMSequenceDictionary samSequenceDictionary = SAMSequenceDictTransfer.transfer(refContigInfo);
    data.genomeLocParser = new GenomeLocParser(samSequenceDictionary);
    samHeaderInfo.addReadGroupInfo(ReadGroupInfo.apply("rg1", "sample1"));
    SAMFileHeader header = SAMHeaderTransfer.transfer(samHeaderInfo);
    List<SAMReadGroupRecord> readGroupInfos = header.getReadGroups();
    List<String> samples = new ArrayList<>();
    for (SAMReadGroupRecord readGroup : readGroupInfos) {
        samples.add(readGroup.getSample());
    }
    data.haplotypeCaller = new HaplotypeCaller(data.genomeLocParser, samples, useGVCF);
    data.basic2SAMRecordTransfer = new Basic2SAMRecordTransfer(header);

    VCFCodec codec = new VCFCodec();
    VCFHeaderLineIterable headerLineIterable = new VCFHeaderLineIterable(vcfHeaderInfo);
    data.vcfFileHeader = (VCFHeader) codec.readActualHeader(headerLineIterable);
    data.codec = codec;
    return data;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:24,代码来源:HaplotypeCallerAdapter.java

示例5: filter

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
public boolean filter(ReferenceContext ref, GATKSAMRecord read) {
    // check that the read belongs to an RG that we need to keep
    if (!readGroupsToKeep.isEmpty()) {
        final SAMReadGroupRecord readGroup = read.getReadGroup();
        if (!readGroupsToKeep.contains(readGroup.getReadGroupId()))
            return false;
    }

    // check if we've reached the output limit
    if (nReadsToPrint == 0) {
        return false;          // n == 0 means we've printed all we needed.
    } else if (nReadsToPrint > 0) {
        nReadsToPrint--;       // n > 0 means there are still reads to be printed.
    }

    return true;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:PrintReads.java

示例6: VariantCallingEngine

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 *  constructor
 * @param options
 * @param samFileHeader
 */
public VariantCallingEngine(GenotyperOptions options, SAMFileHeader samFileHeader) {
    this.options = options;
    genomeLocationParser = new GenomeLocationParser(samFileHeader.getSequenceDictionary());
    samples = new HashSet<>();
    for(SAMReadGroupRecord rg : samFileHeader.getReadGroups()) {
        samples.add(rg.getSample());
    }

    GenotypeLikelihoodCalculator.getGenotypeLikelihoodsCalculatorObject(options);
    GenotypeLikelihoodCalculator.getCalculators(options);

    this.N = samples.size() * options.getSamplePloidy();
    log10AlleleFrequencyPriorsSNPs = new double[N+1];
    log10AlleleFrequencyPriorsIndels = new double[N+1];
    computeAlleleFrequencyPriors(N, log10AlleleFrequencyPriorsSNPs, options.getHeterozygosity());
    computeAlleleFrequencyPriors(N, log10AlleleFrequencyPriorsIndels, options.getIndelHeterozygosity());
    filter.add(LOW_QUAL_FILTER_NAME);
    tracker = new VariantDataTracker();

    annotationEngine = new VariantAnnotatorEngine(options.getAnnotationGroups(), options.getAnnotations(), null);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:27,代码来源:VariantCallingEngine.java

示例7: getPlatforms

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * @param header
 * @return Return the set of platforms, uppercase. Will be null iff header is null
 */
public static Set<String> getPlatforms(SAMFileHeader header) {
    Set<String> platforms = null;
    if (header != null) {
        List<SAMReadGroupRecord> readGroups = header.getReadGroups();
        if (readGroups != null) {
            platforms = new HashSet<String>();
            for (SAMReadGroupRecord rg : readGroups) {
                String platform = rg.getPlatform();
                if (platform != null) {
                    platforms.add(platform.toUpperCase());
                }
            }
        }
    }
    return platforms;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:21,代码来源:AlignmentReaderFactory.java

示例8: createReadGroupRecord

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
protected SAMReadGroupRecord createReadGroupRecord(
        String RGID, String RGLB, String RGPL, 
        String RGPU, String RGSM, String RGCN, 
        String RGDS, Iso8601Date RGDT, Integer RGPI) {
    SAMReadGroupRecord rg = new SAMReadGroupRecord(RGID);
    rg.setLibrary(RGLB);
    rg.setPlatform(RGPL);
    rg.setSample(RGSM);
    rg.setPlatformUnit(RGPU);
    if(RGCN != null)
        rg.setSequencingCenter(RGCN);
    if(RGDS != null)
        rg.setDescription(RGDS);
    if(RGDT != null)
        rg.setRunDate(RGDT);
    if(RGPI != null)
        rg.setPredictedMedianInsertSize(RGPI);
    return rg;
}
 
开发者ID:biointec,项目名称:halvade,代码行数:20,代码来源:HalvadeReducer.java

示例9: buildSamFileWriter

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * Build a SamFileWriter that will write its contents to the output file.
 *
 * @param output           The file to which to write
 * @param sampleAlias      The sample alias set in the read group header
 * @param libraryName      The name of the library to which this read group belongs
 * @param headerParameters Header parameters that will be added to the RG header for this SamFile
 * @return A SAMFileWriter
 */
private SAMFileWriterWrapper buildSamFileWriter(final File output, final String sampleAlias,
                                                final String libraryName, final Map<String, String> headerParameters,
                                                final boolean presorted) {
    IOUtil.assertFileIsWritable(output);
    final SAMReadGroupRecord rg = new SAMReadGroupRecord(READ_GROUP_ID);
    rg.setSample(sampleAlias);

    if (libraryName != null) rg.setLibrary(libraryName);
    for (final Map.Entry<String, String> tagNameToValue : headerParameters.entrySet()) {
        if (tagNameToValue.getValue() != null) {
            rg.setAttribute(tagNameToValue.getKey(), tagNameToValue.getValue());
        }
    }

    final SAMFileHeader header = new SAMFileHeader();

    header.setSortOrder(SAMFileHeader.SortOrder.queryname);
    header.addReadGroup(rg);
    return new SAMFileWriterWrapper(new SAMFileWriterFactory().makeSAMOrBAMWriter(header, presorted, output));
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:30,代码来源:IlluminaBasecallsToSam.java

示例10: createSamFileHeader

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/** Creates a simple header with the values provided on the command line. */
public SAMFileHeader createSamFileHeader() {
    final SAMReadGroupRecord rgroup = new SAMReadGroupRecord(this.READ_GROUP_NAME);
    rgroup.setSample(this.SAMPLE_NAME);
    if (this.LIBRARY_NAME != null) rgroup.setLibrary(this.LIBRARY_NAME);
    if (this.PLATFORM != null) rgroup.setPlatform(this.PLATFORM);
    if (this.PLATFORM_UNIT != null) rgroup.setPlatformUnit(this.PLATFORM_UNIT);
    if (this.SEQUENCING_CENTER != null) rgroup.setSequencingCenter(SEQUENCING_CENTER);
    if (this.PREDICTED_INSERT_SIZE != null) rgroup.setPredictedMedianInsertSize(PREDICTED_INSERT_SIZE);
    if (this.DESCRIPTION != null) rgroup.setDescription(this.DESCRIPTION);
    if (this.RUN_DATE != null) rgroup.setRunDate(this.RUN_DATE);
    if (this.PLATFORM_MODEL != null) rgroup.setPlatformModel(this.PLATFORM_MODEL);
    if (this.PROGRAM_GROUP != null) rgroup.setProgramGroup(this.PROGRAM_GROUP);

    final SAMFileHeader header = new SAMFileHeader();
    header.addReadGroup(rgroup);

    for (final String comment : COMMENT) {
        header.addComment(comment);
    }

    header.setSortOrder(this.SORT_ORDER);
    return header ;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:FastqToSam.java

示例11: makeReadGroupFile

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
private File makeReadGroupFile(final SAMReadGroupRecord readGroup, final String preExtSuffix) {
    String fileName = null;
    if (RG_TAG.equalsIgnoreCase("PU")){
        fileName = readGroup.getPlatformUnit();
    } else if (RG_TAG.equalsIgnoreCase("ID")){
        fileName = readGroup.getReadGroupId();
    }
    if (fileName == null) {
        throw new PicardException("The selected RG_TAG: "+RG_TAG+" is not present in the bam header.");
    }
    fileName = IOUtil.makeFileNameSafe(fileName);
    if (preExtSuffix != null) fileName += preExtSuffix;
    fileName += COMPRESS_OUTPUTS_PER_RG ? ".fastq.gz" : ".fastq";

    final File result = (OUTPUT_DIR != null)
            ? new File(OUTPUT_DIR, fileName)
            : new File(fileName);
    IOUtil.assertFileIsWritable(result);
    return result;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:21,代码来源:SamToFastq.java

示例12: splitByLibrary

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * Takes a list of PairedReadSequence objects and splits them into lists by library.
 */
Map<String, List<PairedReadSequence>> splitByLibrary(final List<PairedReadSequence> input,
                                                     final List<SAMReadGroupRecord> rgs) {

    final Map<String, List<PairedReadSequence>> out = new HashMap<>();
    for (final PairedReadSequence seq : input) {
        String library = null;
        if (seq.getReadGroup() != -1) {
            library = rgs.get(seq.getReadGroup()).getLibrary();
            if (library == null) library = "Unknown";
        } else {
            library = "Unknown";
        }

        List<PairedReadSequence> librarySeqs = out.get(library);
        if (librarySeqs == null) {
            librarySeqs = new ArrayList<>();
            out.put(library, librarySeqs);
        }
        librarySeqs.add(seq);
    }

    return out;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:27,代码来源:EstimateLibraryComplexityGATK.java

示例13: saveResults

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
private void saveResults(final MetricsFile<?, Integer> metrics, final SAMFileHeader readsHeader, final String inputFileName){
    MetricsUtils.saveMetrics(metrics, out);

    if (metrics.getAllHistograms().isEmpty()) {
        logger.warn("No valid bases found in input file.");
    } else if (chartOutput != null){
        // Now run R to generate a chart

        // If we're working with a single library, assign that library's name
        // as a suffix to the plot title
        final List<SAMReadGroupRecord> readGroups = readsHeader.getReadGroups();

        /*
         * A subtitle for the plot, usually corresponding to a library.
         */
        String plotSubtitle = "";
        if (readGroups.size() == 1) {
            plotSubtitle = StringUtil.asEmptyIfNull(readGroups.get(0).getLibrary());
        }
        final RScriptExecutor executor = new RScriptExecutor();
        executor.addScript(getMeanQualityByCycleRScriptResource());
        executor.addArgs(out, chartOutput.getAbsolutePath(), inputFileName, plotSubtitle);
        executor.exec();
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:26,代码来源:MeanQualityByCycleSpark.java

示例14: acceptRecord

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/** Call acceptRecord(args) on the record collector identified by getKey */
public void acceptRecord(final ARGTYPE args, final SAMReadGroupRecord rg) {

    String key = UNKNOWN;
    if(rg != null) {
        final String computedKey = getKey(rg);
        if(computedKey != null) {
            key = computedKey;
        }
    }
    PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> collector = collectors.get(key);
    if (collector == null) {
        if (!UNKNOWN.equals(key)) {
            throw new PicardException("Could not find collector for " + key);
        }
        collector = makeUnknownCollector();
        collectors.put(key, collector);
    }
    collector.acceptRecord(args);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:21,代码来源:MultiLevelCollector.java

示例15: HaplotypeBAMDestination

import htsjdk.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
 * Create a new HaplotypeBAMDestination
 *
 * @param sourceHeader SAMFileHeader used to seed the output SAMFileHeader for this destination.
 * @param haplotypeReadGroupID read group ID used when writing haplotypes as reads
 */
protected HaplotypeBAMDestination(SAMFileHeader sourceHeader, final String haplotypeReadGroupID) {
    Utils.nonNull(sourceHeader, "sourceHeader cannot be null");
    Utils.nonNull(haplotypeReadGroupID, "haplotypeReadGroupID cannot be null");
    this.haplotypeReadGroupID = haplotypeReadGroupID;

    bamOutputHeader = new SAMFileHeader();
    bamOutputHeader.setSequenceDictionary(sourceHeader.getSequenceDictionary());
    bamOutputHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);

    final List<SAMReadGroupRecord> readGroups = new ArrayList<>();
    readGroups.addAll(sourceHeader.getReadGroups()); // include the original read groups

    // plus an artificial read group for the haplotypes
    final SAMReadGroupRecord rgRec = new SAMReadGroupRecord(getHaplotypeReadGroupID());
    rgRec.setSample(haplotypeSampleTag);
    rgRec.setSequencingCenter("BI");
    readGroups.add(rgRec);
    bamOutputHeader.setReadGroups(readGroups);

    bamOutputHeader.addProgramRecord(new SAMProgramRecord("HalpotypeBAMWriter"));
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:28,代码来源:HaplotypeBAMDestination.java


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