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

Java SortingCollection类代码示例

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

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



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

示例1: addRecord

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
private synchronized void addRecord(final String barcode, final CLUSTER_OUTPUT_RECORD record) {
    // Grab the existing collection, or initialize it if it doesn't yet exist
    SortingCollection<CLUSTER_OUTPUT_RECORD> recordCollection = this.barcodeToRecordCollection.get(barcode);
    if (recordCollection == null) {
        // TODO: The implementation here for supporting ignoreUnexpectedBarcodes is not efficient,
        // but the alternative is an extensive rewrite.  We are living with the inefficiency for
        // this special case for the time being.
        if (!barcodeRecordWriterMap.containsKey(barcode)) {
            if (ignoreUnexpectedBarcodes) {
                return;
            }
            throw new PicardException(String.format("Read records with barcode %s, but this barcode was not expected.  (Is it referenced in the parameters file?)", barcode));
        }
        recordCollection = newSortingCollection();
        this.barcodeToRecordCollection.put(barcode, recordCollection);
    }
    recordCollection.add(record);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:19,代码来源:NewIlluminaBasecallsConverter.java


示例2: IlluminaBasecallsConverter

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * @param basecallsDir             Where to read basecalls from.
 * @param lane                     What lane to process.
 * @param readStructure            How to interpret each cluster.
 * @param barcodeRecordWriterMap   Map from barcode to CLUSTER_OUTPUT_RECORD writer.  If demultiplex is false, must contain
 *                                 one writer stored with key=null.
 * @param demultiplex              If true, output is split by barcode, otherwise all are written to the same output stream.
 * @param maxReadsInRamPerTile     Configures number of reads each tile will store in RAM before spilling to disk.
 * @param tmpDirs                  For SortingCollection spilling.
 * @param numProcessors            Controls number of threads.  If <= 0, the number of threads allocated is
 *                                 available cores - numProcessors.
 * @param forceGc                  Force explicit GC periodically.  This is good for causing memory maps to be released.
 * @param firstTile                (For debugging) If non-null, start processing at this tile.
 * @param tileLimit                (For debugging) If non-null, process no more than this many tiles.
 * @param outputRecordComparator   For sorting output records within a single tile.
 * @param codecPrototype           For spilling output records to disk.
 * @param outputRecordClass        Inconveniently needed to create SortingCollections.
 * @param includeNonPfReads        If true, will include ALL reads (including those which do not have PF set)
 * @param ignoreUnexpectedBarcodes If true, will ignore reads whose called barcode is not found in barcodeRecordWriterMap,
 *                                 otherwise will throw an exception
 */
public IlluminaBasecallsConverter(final File basecallsDir, final int lane, final ReadStructure readStructure,
                                  final Map<String, ? extends ConvertedClusterDataWriter<CLUSTER_OUTPUT_RECORD>> barcodeRecordWriterMap,
                                  final boolean demultiplex,
                                  final int maxReadsInRamPerTile,
                                  final List<File> tmpDirs,
                                  final int numProcessors, final boolean forceGc,
                                  final Integer firstTile, final Integer tileLimit,
                                  final Comparator<CLUSTER_OUTPUT_RECORD> outputRecordComparator,
                                  final SortingCollection.Codec<CLUSTER_OUTPUT_RECORD> codecPrototype,
                                  final Class<CLUSTER_OUTPUT_RECORD> outputRecordClass,
                                  final BclQualityEvaluationStrategy bclQualityEvaluationStrategy,
                                  final boolean applyEamssFiltering,
                                  final boolean includeNonPfReads,
                                  final boolean ignoreUnexpectedBarcodes
) {
    this(basecallsDir, null, lane, readStructure,
            barcodeRecordWriterMap, demultiplex, maxReadsInRamPerTile,
            tmpDirs, numProcessors, forceGc, firstTile, tileLimit,
            outputRecordComparator, codecPrototype, outputRecordClass,
            bclQualityEvaluationStrategy, applyEamssFiltering,
            includeNonPfReads, ignoreUnexpectedBarcodes);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:44,代码来源:IlluminaBasecallsConverter.java


示例3: addRecord

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * Adds the provided record to this tile.
 */
public synchronized void addRecord(final String barcode, final CLUSTER_OUTPUT_RECORD record) {
    this.recordCount += 1;

    // Grab the existing collection, or initialize it if it doesn't yet exist
    SortingCollection<CLUSTER_OUTPUT_RECORD> recordCollection = this.barcodeToRecordCollection.get(barcode);
    if (recordCollection == null) {
        // TODO: The implementation here for supporting ignoreUnexpectedBarcodes is not efficient,
        // but the alternative is an extensive rewrite.  We are living with the inefficiency for
        // this special case for the time being.
        if (!barcodeRecordWriterMap.containsKey(barcode)) {
            if (ignoreUnexpectedBarcodes) {
                return;
            }
            throw new PicardException(String.format("Read records with barcode %s, but this barcode was not expected.  (Is it referenced in the parameters file?)", barcode));
        }
        recordCollection = this.newSortingCollection();
        this.barcodeToRecordCollection.put(barcode, recordCollection);
        this.barcodeToProcessingState.put(barcode, null);
    }
    recordCollection.add(record);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:IlluminaBasecallsConverter.java


示例4: RevertSamSorter

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
RevertSamSorter(
        final boolean outputByReadGroup,
        final Map<String, SAMFileHeader> headerMap,
        final SAMFileHeader singleOutHeader,
        final int maxRecordsInRam) {

    this.outputByReadGroup = outputByReadGroup;
    if (outputByReadGroup) {
        for (final Map.Entry<String, SAMFileHeader> entry : headerMap.entrySet()) {
            final String readGroupId = entry.getKey();
            final SAMFileHeader outHeader = entry.getValue();
            final SortingCollection<SAMRecord> sorter = SortingCollection.newInstance(SAMRecord.class, new BAMRecordCodec(outHeader), new SAMRecordQueryNameComparator(), maxRecordsInRam);
            sorterMap.put(readGroupId, sorter);
        }
        singleSorter = null;
    } else {
        singleSorter = SortingCollection.newInstance(SAMRecord.class, new BAMRecordCodec(singleOutHeader), new SAMRecordQueryNameComparator(), maxRecordsInRam);
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:20,代码来源:RevertSam.java


示例5: sortInputs

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * Merge the inputs and sort them by adding each input's content to a single SortingCollection.
 * <p/>
 * NB: It would be better to have a merging iterator as in MergeSamFiles, as this would perform better for pre-sorted inputs.
 * Here, we are assuming inputs are unsorted, and so adding their VariantContexts iteratively is fine for now.
 * MergeVcfs exists for simple merging of presorted inputs.
 *
 * @param readers      - a list of VCFFileReaders, one for each input VCF
 * @param outputHeader - The merged header whose information we intend to use in the final output file
 */
private SortingCollection<VariantContext> sortInputs(final List<VCFFileReader> readers, final VCFHeader outputHeader) {
    final ProgressLogger readProgress = new ProgressLogger(log, 25000, "read", "records");

    // NB: The default MAX_RECORDS_IN_RAM may not be appropriate here. VariantContexts are smaller than SamRecords
    // We would have to play around empirically to find an appropriate value. We are not performing this optimization at this time.
    final SortingCollection<VariantContext> sorter =
            SortingCollection.newInstance(
                    VariantContext.class,
                    new VCFRecordCodec(outputHeader, VALIDATION_STRINGENCY != ValidationStringency.STRICT),
                    outputHeader.getVCFRecordComparator(),
                    MAX_RECORDS_IN_RAM,
                    TMP_DIR);
    int readerCount = 1;
    for (final VCFFileReader reader : readers) {
        log.info("Reading entries from input file " + readerCount);
        for (final VariantContext variantContext : reader) {
            sorter.add(variantContext);
            readProgress.record(variantContext.getContig(), variantContext.getStart());
        }
        reader.close();
        readerCount++;
    }
    return sorter;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:35,代码来源:SortVcf.java


示例6: clone

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
@Override
public SortingCollection.Codec<SortableRecord> clone() {
    try {
        return (SortingCollection.Codec<SortableRecord>) super.clone();
    } catch (CloneNotSupportedException e) {
        throw new SortingException(e);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:9,代码来源:SortableRecordCodec.java


示例7: run

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * @param maxMemory - in megabytes
 * @throws IOException
 *
 */
public void run(int maxMemory) throws IOException {
    try (
            PrintWriter writer = NgbFileUtils.isGzCompressed(outputFile.getName()) ?
                    new PrintWriter(new OutputStreamWriter(new BlockCompressedOutputStream(outputFile), UTF_8)) :
                    new PrintWriter(outputFile, UTF_8);
            AsciiLineReader reader = NgbFileUtils.isGzCompressed(outputFile.getName()) ?
                    new AsciiLineReader(new BlockCompressedInputStream(inputFile)) :
                    new AsciiLineReader(new FileInputStream(inputFile))
    ) {

        SortableRecordCodec codec = new SortableRecordCodec();

        SortingCollection cltn = SortingCollection.newInstance(
                SortableRecord.class, codec, comparator, maxMemory * 1024 * 1024 / ESTIMATED_RECORD_SIZE, tmpDir);

        Parser parser = getParser();

        String firstDataRow = writeHeader(reader, writer);
        if (firstDataRow != null && !firstDataRow.isEmpty()) {
            cltn.add(parser.createRecord(firstDataRow));
        }

        SortableRecord next;
        while ((next = parser.readNextRecord(reader)) != null) {
            cltn.add(next);
        }

        CloseableIterator<SortableRecord> iter = cltn.iterator();
        while (iter.hasNext()) {
            SortableRecord al = iter.next();
            writer.println(al.getText());

        }
        iter.close();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:42,代码来源:AbstractFeatureSorter.java


示例8: run

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * @param maxMemory - in megabytes
 * @throws IOException
 *
 */
public void run(int maxMemory) throws IOException {
    try (
            PrintWriter writer = NgbFileUtils.isGzCompressed(outputFile.getName()) ?
                    new PrintWriter(new OutputStreamWriter(new BlockCompressedOutputStream(outputFile), UTF_8)) :
                    new PrintWriter(outputFile, UTF_8);
            AsciiLineReader reader = NgbFileUtils.isGzCompressed(inputFile.getName()) ?
                    new AsciiLineReader(new BlockCompressedInputStream(inputFile)) :
                    new AsciiLineReader(new FileInputStream(inputFile))
    ) {

        SortableRecordCodec codec = new SortableRecordCodec();

        SortingCollection cltn = SortingCollection.newInstance(
                SortableRecord.class, codec, comparator, maxMemory * 1024 * 1024 / ESTIMATED_RECORD_SIZE, tmpDir);

        Parser parser = getParser();

        String firstDataRow = writeHeader(reader, writer);
        if (firstDataRow != null && !firstDataRow.isEmpty()) {
            cltn.add(parser.createRecord(firstDataRow));
        }

        SortableRecord next;
        while ((next = parser.readNextRecord(reader)) != null) {
            cltn.add(next);
        }

        CloseableIterator<SortableRecord> iter = cltn.iterator();
        while (iter.hasNext()) {
            SortableRecord al = iter.next();
            writer.println(al.getText());

        }
        iter.close();
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:42,代码来源:AbstractFeatureSorter.java


示例9: newSortingCollection

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
private synchronized SortingCollection<CLUSTER_OUTPUT_RECORD> newSortingCollection() {
    final int maxRecordsInRam =
            Math.max(1, maxReadsInRamPerTile /
                    barcodeRecordWriterMap.size());
    return SortingCollection.newInstance(
            outputRecordClass,
            codecPrototype.clone(),
            outputRecordComparator,
            maxRecordsInRam,
            tmpDirs);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:12,代码来源:NewIlluminaBasecallsConverter.java


示例10: BasecallsConverter

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * @param barcodeRecordWriterMap   Map from barcode to CLUSTER_OUTPUT_RECORD writer.  If demultiplex is false, must contain
 *                                 one writer stored with key=null.
 * @param demultiplex              If true, output is split by barcode, otherwise all are written to the same output stream.
 * @param maxReadsInRamPerTile     Configures number of reads each tile will store in RAM before spilling to disk.
 * @param tmpDirs                  For SortingCollection spilling.
 * @param numProcessors            Controls number of threads.  If <= 0, the number of threads allocated is
 *                                 available cores - numProcessors.
 * @param outputRecordComparator   For sorting output records within a single tile.
 * @param codecPrototype           For spilling output records to disk.
 * @param outputRecordClass        Inconveniently needed to create SortingCollections.
 * @param ignoreUnexpectedBarcodes If true, will ignore reads whose called barcode is not found in barcodeRecordWriterMap,
 */
BasecallsConverter(final Map<String, ? extends ConvertedClusterDataWriter<CLUSTER_OUTPUT_RECORD>> barcodeRecordWriterMap,
                   final int maxReadsInRamPerTile,
                   final List<File> tmpDirs,
                   final SortingCollection.Codec<CLUSTER_OUTPUT_RECORD> codecPrototype,
                   final boolean ignoreUnexpectedBarcodes,
                   final boolean demultiplex,
                   final Comparator<CLUSTER_OUTPUT_RECORD> outputRecordComparator,
                   final BclQualityEvaluationStrategy bclQualityEvaluationStrategy,
                   final Class<CLUSTER_OUTPUT_RECORD> outputRecordClass,
                   final int numProcessors,
                   final IlluminaDataProviderFactory factory) {

    this.barcodeRecordWriterMap = barcodeRecordWriterMap;
    this.maxReadsInRamPerTile = maxReadsInRamPerTile;
    this.tmpDirs = tmpDirs;
    this.codecPrototype = codecPrototype;
    this.ignoreUnexpectedBarcodes = ignoreUnexpectedBarcodes;
    this.demultiplex = demultiplex;
    this.outputRecordComparator = outputRecordComparator;
    this.bclQualityEvaluationStrategy = bclQualityEvaluationStrategy;
    this.outputRecordClass = outputRecordClass;
    this.factory = factory;


    if (numProcessors == 0) {
        this.numThreads = Runtime.getRuntime().availableProcessors();
    } else if (numProcessors < 0) {
        this.numThreads = Runtime.getRuntime().availableProcessors() + numProcessors;
    } else {
        this.numThreads = numProcessors;
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:46,代码来源:BasecallsConverter.java


示例11: add

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
void add(final SAMRecord rec) {
    final SortingCollection<SAMRecord> sorter;
    if (outputByReadGroup) {
        sorter = sorterMap.get(rec.getReadGroup().getId());
    } else {
        sorter = singleSorter;
    }
    sorter.add(rec);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:RevertSam.java


示例12: makeSortingCollection

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
private SortingCollection<String> makeSortingCollection() {
    final String name = getClass().getSimpleName();
    final File tmpDir = IOUtil.createTempDir(name, null);
    tmpDir.deleteOnExit();
    // 256 byte for one name, and 1/10 part of all memory for this, rough estimate
    long maxNamesInRam = Runtime.getRuntime().maxMemory() / 256 / 10;
    return SortingCollection.newInstance(
            String.class,
            new StringCodec(),
            String::compareTo,
            (int) Math.min(maxNamesInRam, Integer.MAX_VALUE),
            tmpDir
    );
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:15,代码来源:CreateSequenceDictionary.java


示例13: doWork

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
@Override
protected int doWork() {
    final List<String> sampleList = new ArrayList<String>();

    for (final File input : INPUT) IOUtil.assertFileIsReadable(input);

    if (SEQUENCE_DICTIONARY != null) IOUtil.assertFileIsReadable(SEQUENCE_DICTIONARY);

    SAMSequenceDictionary samSequenceDictionary = null;
    if (SEQUENCE_DICTIONARY != null) {
        samSequenceDictionary = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).getFileHeader(SEQUENCE_DICTIONARY).getSequenceDictionary();
        CloserUtil.close(SEQUENCE_DICTIONARY);
    }

    // Gather up a file reader and file header for each input file. Check for sequence dictionary compatibility along the way.
    collectFileReadersAndHeaders(sampleList, samSequenceDictionary);

    // Create the merged output header from the input headers
    final VCFHeader outputHeader = new VCFHeader(VCFUtils.smartMergeHeaders(inputHeaders, false), sampleList);

    // Load entries into the sorting collection
    final SortingCollection<VariantContext> sortedOutput = sortInputs(inputReaders, outputHeader);

    // Output to the final file
    writeSortedOutput(outputHeader, sortedOutput);

    return 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:29,代码来源:SortVcf.java


示例14: writeSortedOutput

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
private void writeSortedOutput(final VCFHeader outputHeader, final SortingCollection<VariantContext> sortedOutput) {
    final ProgressLogger writeProgress = new ProgressLogger(log, 25000, "wrote", "records");
    final EnumSet<Options> options = CREATE_INDEX ? EnumSet.of(Options.INDEX_ON_THE_FLY) : EnumSet.noneOf(Options.class);
    final VariantContextWriter out = new VariantContextWriterBuilder().
            setReferenceDictionary(outputHeader.getSequenceDictionary()).
            setOptions(options).
            setOutputFile(OUTPUT).build();
    out.writeHeader(outputHeader);
    for (final VariantContext variantContext : sortedOutput) {
        out.add(variantContext);
        writeProgress.record(variantContext.getContig(), variantContext.getStart());
    }
    out.close();
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:15,代码来源:SortVcf.java


示例15: runSingle

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
private void runSingle(final FastqReader r1,final FastqWriter w1) throws IOException
{
long nReads=0;
final  SortingCollection<OneRead> sorting= SortingCollection.newInstance(
		OneRead.class,
		new OneReadCodec(),
		new OneReadCompare(),
		this.writingSortingCollection.getMaxRecordsInRam(),
		this.writingSortingCollection.getTmpPaths()
		);
sorting.setDestructiveIteration(true);
while(r1.hasNext())
	{
	final OneRead r=new OneRead();
	r.random=this.random.nextLong();
	r.index=nReads;
	r.first=r1.next();
	
	if((++nReads)%this.writingSortingCollection.getMaxRecordsInRam()==0)
		{
		LOG.info("Read "+nReads+" reads");
		}

	
	sorting.add(r);
	}
sorting.doneAdding();

final CloseableIterator<OneRead> iter=sorting.iterator();
while(iter.hasNext())
	{
	final OneRead p=iter.next();
	w1.write(p.first);
	}

	
CloserUtil.close(iter);
sorting.cleanup();
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:40,代码来源:FastqShuffle.java


示例16: writeHeader

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
@Override
public void writeHeader(VCFHeader header) {
	this.delegate.writeHeader(header);			
	this.sorter =
               SortingCollection.newInstance(
                       VariantContext.class,
                       new VCFRecordCodec(header),
                       header.getVCFRecordComparator(),
                       VcfIndexTabix.this.writingSortingCollection.getMaxRecordsInRam(),
                       VcfIndexTabix.this.writingSortingCollection.getTmpPaths()
                       );
	
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:14,代码来源:VcfIndexTabix.java


示例17: newInstance

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
public static SortingCollection<VcfLine> newInstance(int maxRecords, String tempDir) {
	return SortingCollection.newInstance(VcfLine.class, new VcfLineCodec(), new VcfLineComparator(), maxRecords,
			new File(tempDir));
}
 
开发者ID:genepi,项目名称:imputationserver,代码行数:5,代码来源:VcfLineSortingCollection.java


示例18: run

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
public void run() throws IOException {

        FileInputStream fis = null;
        PrintWriter writer = null;

        try {
            fis = new FileInputStream(inputFile);
            Writer rawWriter;
            if (writeStdOut) {
                rawWriter = new OutputStreamWriter(System.out);
            } else {
                rawWriter = new FileWriter(this.outputFile);
            }
            writer = new PrintWriter(new BufferedWriter(rawWriter));

            SortableRecordCodec codec = new SortableRecordCodec();

            SortingCollection cltn = SortingCollection.newInstance(SortableRecord.class, codec, comparator, maxRecords, tmpDir);

            Parser parser = getParser();
            AsciiLineReader reader = new AsciiLineReader(fis);

            String firstDataRow = writeHeader(reader, writer);
            if (firstDataRow != null) {
                cltn.add(parser.createRecord(firstDataRow));
            }

            SortableRecord next = null;
            while ((next = parser.readNextRecord(reader)) != null) {
                cltn.add(next);
            }


            CloseableIterator<SortableRecord> iter = cltn.iterator();
            while (iter.hasNext()) {
                SortableRecord al = iter.next();
                writer.println(al.getText());

            }
            iter.close();
        } finally {
            if (fis != null) fis.close();
            if (writer != null) writer.close();
        }
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:46,代码来源:AsciiSorter.java


示例19: clone

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
public SortingCollection.Codec<SortableRecord> clone() {
    SortableRecordCodec other = new SortableRecordCodec();
    return other;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:5,代码来源:SortableRecordCodec.java


示例20: convert

import htsjdk.samtools.util.SortingCollection; //导入依赖的package包/类
/**
 * Parse the file and output in ".igv" format
 *
 * @return
 */
public static void convert(ResourceLocator resourceLocator, File outputFile, String probeResource,
                    int maxRecords, File tmpDir, Genome genome) throws IOException {

    ExpressionFileParser.FileType type = ExpressionFileParser.determineType(resourceLocator);

    GeneToLocusHelper locusHelper = new GeneToLocusHelper(probeResource);


    BufferedReader reader = null;
    PrintWriter writer = null;

    SortingCollection cltn = getSortingCollection(maxRecords, tmpDir);
    try {
        reader = new BufferedReader(new InputStreamReader(ParsingUtils.openInputStream(resourceLocator.getPath())));
        writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));

        ExpressionFileParser.FormatDescriptor formatDescriptor = ExpressionFileParser.parseHeader (reader, type, null);
        String [] dataHeadings = formatDescriptor.getDataHeaders();


        // Need a better way to determine type!
        String dataType = resourceLocator.getPath().contains("methylation") ? TrackType.DNA_METHYLATION.toString()
                : TrackType.GENE_EXPRESSION.toString();

        writer.println("#type=" + dataType);
        writer.print("Chr\tStart\tEnd\tProbe");
        for (String s : dataHeadings) {
            writer.print("\t" + s);
        }
        writer.println();

        String nextLine = null;
        while ((nextLine = reader.readLine()) != null) {

            // A gct row can map to multiple loci, normally this indicates a problem with the probe
            DataRow row = new DataRow(nextLine, formatDescriptor);
            String probe = row.getProbe();
            List<Locus> loci = locusHelper.getLoci(probe, row.getDescription(), genome.getId());
            if (loci == null || loci.isEmpty()) {
                log.warn("No locus found for: " + probe + "  " + row.getDescription());
            } else {
                for (Locus locus : loci) {
                    String igvLine = locus.getChr() + "\t" + locus.getStart() + "\t" + locus.getEnd() + "\t" + probe +
                            "\t" + row.getData();
                    cltn.add(new SortableRecord(locus.getChr(), locus.getStart(), igvLine));
                }
            }
        }


        // Ouputput the sorted file
        CloseableIterator<SortableRecord> iter = cltn.iterator();
        while (iter.hasNext()) {
            SortableRecord al = iter.next();
            writer.println(al.getText());

        }
    } finally {
        if (reader != null) {
            reader.close();
        }
        if (writer != null) {
            writer.close();
        }
    }

}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:73,代码来源:GCTtoIGVConverter.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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