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


Java Feature类代码示例

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


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

示例1: makeTabixCompressedIndex

import htsjdk.tribble.Feature; //导入依赖的package包/类
private void makeTabixCompressedIndex(final File sourceFile, final File indexFile, final AsciiFeatureCodec codec,
                                      final TabixFormat format) throws IOException {
    TabixIndexCreator indexCreator = new TabixIndexCreator(format);

    try (
        BlockCompressedInputStream inputStream = new BlockCompressedInputStream(
            new FileInputStream(sourceFile));
        LittleEndianOutputStream outputStream = new LittleEndianOutputStream(
            new BlockCompressedOutputStream(indexFile))
    ) {
        long p = 0;
        String line = inputStream.readLine();

        while (line != null) {
            //add the feature to the index
            Feature decode = codec.decode(line);
            if (decode != null) {
                indexCreator.addFeature(decode, p);
            }
            // read the next line if available
            p = inputStream.getFilePointer();
            line = inputStream.readLine();
        }

        // write the index to a file
        Index index = indexCreator.finalizeIndex(p);
        // VERY important! either use write based on input file or pass the little endian a BGZF stream
        index.write(outputStream);
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:31,代码来源:FileManager.java

示例2: getPrioritizedValue

import htsjdk.tribble.Feature; //导入依赖的package包/类
/**
 * Same logic as @link #getFirstValue(RodBinding, boolean) but prioritizes records from prioritizeThisLoc if available
 *
 * @param rodBindings       Only Features coming from the tracks associated with one of rodBindings are fetched
 * @param <T>               The Tribble Feature type of the rodBinding, and consequently the type of the resulting list of Features
 * @param prioritizeThisLoc only Features starting at this site are considered
 * @return A freshly allocated list of all of the bindings, or an empty list if none are bound.
 */
public <T extends Feature> List<T> getPrioritizedValue(final Collection<RodBinding<T>> rodBindings, final GenomeLoc prioritizeThisLoc) {
    final List<T> results = new ArrayList<>();

    for (final RodBinding<T> rodBinding : rodBindings) {

        // if there's a value at the prioritized location, take it
        T value = getFirstValue(rodBinding, prioritizeThisLoc);

        // otherwise, grab any one
        if (value == null)
            value = getFirstValue(rodBinding);

        // add if not null
        if (value != null)
            results.add(value);
    }

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

示例3: calculateKnownSites

import htsjdk.tribble.Feature; //导入依赖的package包/类
protected static boolean[] calculateKnownSites( final GATKSAMRecord read, final List<Feature> features ) {
    final int readLength = read.getReadBases().length;
    final boolean[] knownSites = new boolean[readLength];
    Arrays.fill(knownSites, false);
    for( final Feature f : features ) {
        int featureStartOnRead = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), f.getStart(), ReadUtils.ClippingTail.LEFT_TAIL, true); // BUGBUG: should I use LEFT_TAIL here?
        if( featureStartOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) {
            featureStartOnRead = 0;
        }

        int featureEndOnRead = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), f.getEnd(), ReadUtils.ClippingTail.LEFT_TAIL, true);
        if( featureEndOnRead == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) {
            featureEndOnRead = readLength;
        }

        if( featureStartOnRead > readLength ) {
            featureStartOnRead = featureEndOnRead = readLength;
        }

        Arrays.fill(knownSites, Math.max(0, featureStartOnRead), Math.min(readLength, featureEndOnRead + 1), true);
    }
    return knownSites;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:24,代码来源:BaseRecalibrator.java

示例4: checkNextChromosome

import htsjdk.tribble.Feature; //导入依赖的package包/类
private String checkNextChromosome(Feature feature, String currentChromosomeName,
                                   Map<String, Chromosome> chromosomeMap, List<FeatureIndexEntry> allEntries,
                                   GeneFile geneFile) throws IOException {
    if (!feature.getContig().equals(currentChromosomeName)) {
        if (currentChromosomeName != null && (chromosomeMap.containsKey(currentChromosomeName) ||
                                  chromosomeMap.containsKey(Utils.changeChromosomeName(currentChromosomeName)))) {

            featureIndexDao.writeLuceneIndexForFile(geneFile, allEntries);
            LOGGER.info(MessageHelper.getMessage(
                MessagesConstants.INFO_FEATURE_INDEX_CHROMOSOME_WROTE, currentChromosomeName));
            allEntries.clear();
        }

        return feature.getContig();
    }

    return currentChromosomeName;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:19,代码来源:FeatureIndexManager.java

示例5: getNextContig

import htsjdk.tribble.Feature; //导入依赖的package包/类
private String getNextContig(String currentContig, CloseableIterator<? extends Feature> iterator,
                             Map<String, Chromosome> chromosomeMap) {
    Chromosome currentChromosome = Utils.getFromChromosomeMap(chromosomeMap, currentContig);
    if (currentChromosome == null) {
        while (iterator.hasNext()) {
            Feature feature = iterator.next();
            if (Utils.chromosomeMapContains(chromosomeMap, feature.getContig())) {
                return feature.getContig();
            }
        }

        return null;
    }

    return currentContig;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:17,代码来源:BedManager.java

示例6: createIndex

import htsjdk.tribble.Feature; //导入依赖的package包/类
private static Index createIndex(final File inputFile, final FeatureIterator iterator,
        final IndexCreator creator) {
    Feature lastFeature = null;
    Feature currentFeature;
    final Map<String, Feature> visitedChromos = new HashMap<>(40);
    while (iterator.hasNext()) {
        final long position = iterator.getPosition();
        currentFeature = iterator.next();

        checkSorted(inputFile, lastFeature, currentFeature, visitedChromos);

        creator.addFeature(currentFeature, position);
        lastFeature = currentFeature;
    }

    iterator.close();
    return creator.finalizeIndex(iterator.getPosition());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:19,代码来源:IndexUtils.java

示例7: checkFileSorted

import htsjdk.tribble.Feature; //导入依赖的package包/类
public static  <F extends Feature, S> int checkFileSorted(File ofile, final FeatureCodec<F, S> codec)
        throws IOException {
    int numlines = 0;

    AbstractFeatureReader<F, S> reader =
            AbstractFeatureReader.getFeatureReader(ofile.getAbsolutePath(), codec, false);
    CloseableTribbleIterator<F> iterator = reader.iterator();

    final Map<String, Feature> visitedChromos = new HashMap<>(40);
    Feature lastFeature = null;
    while (iterator.hasNext()) {
        Feature currentFeature = iterator.next();
        numlines++;

        checkSorted(ofile, lastFeature, currentFeature, visitedChromos);

        lastFeature = currentFeature;
    }

    return numlines;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:22,代码来源:SortTest.java

示例8: initFeatures

import htsjdk.tribble.Feature; //导入依赖的package包/类
private void initFeatures(Iterable<? extends Feature> allFeatures) {
    // Separate features by chromosome

        featureMap = new HashMap();
        for (Feature f : allFeatures) {
            List<Feature> fList = featureMap.get(f.getChr());
            if (fList == null) {
                fList = new ArrayList();
                featureMap.put(f.getChr(), fList);
            }
            fList.add(f);
        }

        for (List<Feature> featureList : featureMap.values()) {
            FeatureUtils.sortFeatureList(featureList);
        }

        if (featureMap.size() < 100) {
            sampleGenomeFeatures();
        }
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:22,代码来源:FeatureCollectionSource.java

示例9: getCopyDetailsItem

import htsjdk.tribble.Feature; //导入依赖的package包/类
public static JMenuItem getCopyDetailsItem(final Feature f, final TrackClickEvent evt) {
    JMenuItem item = new JMenuItem("Copy Details to Clipboard");
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            ReferenceFrame frame = evt.getFrame();
            int mouseX = evt.getMouseEvent().getX();

            double location = frame.getChromosomePosition(mouseX);
            if (f instanceof IGVFeature) {
                String details = ((IGVFeature) f).getValueString(location, null);
                if (details != null) {
                    details = details.replace("<br>", System.getProperty("line.separator"));
                    details += System.getProperty("line.separator") +
                            f.getChr() + ":" + (f.getStart() + 1) + "-" + f.getEnd();
                    StringUtils.copyTextToClipboard(details);
                }
            }
        }
    });
    return item;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:TrackMenuUtils.java

示例10: queryRaw

import htsjdk.tribble.Feature; //导入依赖的package包/类
@Override
protected Iterator<Feature> queryRaw(String chr, int start, int end) throws IOException {

    // Tribble iterators must be closed, so we need to copy the features and insure closure before exiting.
    CloseableTribbleIterator<Feature> iter = null;
    try {
        iter = tribbleFeatureReader.query(chr, start, end);
        List<Feature> featureList = new ArrayList<Feature>();
        while (iter.hasNext()) {
            Feature f = iter.next();
            if (f.getStart() > end) {
                break;
            } else if (f.getEnd() < start) {
                continue;
            } else {
                featureList.add(f);
            }
        }
        return featureList.iterator();
    } finally {
        if (iter != null) iter.close();
    }
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:CachingFeatureReader.java

示例11: compare

import htsjdk.tribble.Feature; //导入依赖的package包/类
public int compare(Feature feat1, Feature feat2) {

            // Prefer the shortest chromosome name.  Longer names are most likely "weird"
            // e.g.  chr1_gl000191_random
            int nameLen1 = feat1.getChr().length();
            int nameLen2 = feat2.getChr().length();
            if (nameLen1 != nameLen2) {
                return nameLen1 - nameLen2;
            }


            int len1 = (feat1.getEnd() - feat1.getStart());
            int len2 = (feat2.getEnd() - feat2.getStart());
            int toRet;
            if (!this.descending) {
                toRet = len1 - len2;
            } else {
                toRet = len2 - len1;
            }

            return toRet;

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

示例12: getFeatureClosest

import htsjdk.tribble.Feature; //导入依赖的package包/类
public static Feature getFeatureClosest(double position, List<? extends htsjdk.tribble.Feature> features) {
    // look for exact match at position:
    htsjdk.tribble.Feature f0 = getFeatureAt(position, features);
    if (f0 != null) {
        return f0;
    }
    // otherwise look for features on either side and return the closest:
    htsjdk.tribble.Feature f1 = getFeatureBefore(position, features);
    htsjdk.tribble.Feature f2 = getFeatureAfter(position, features);

    double d1 = f1 == null ? Double.MAX_VALUE : Math.abs(position - f1.getEnd());
    double d2 = f2 == null ? Double.MAX_VALUE : Math.abs(f2.getStart() - position);

    return (d1 < d2 ? f1 : f2);

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

示例13: writeFeaturesToStream

import htsjdk.tribble.Feature; //导入依赖的package包/类
/**
 * Stream will be closed after data written
 *
 * @param features
 * @param outputStream
 * @return
 */
private int writeFeaturesToStream(Iterator<Feature> features, OutputStream outputStream) {
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream));

    int allNumCols = -1;
    if (features != null) {
        IGVBEDCodec codec = new IGVBEDCodec();
        while (features.hasNext()) {
            String data = codec.encode(features.next());

            writer.println(data);

            //We require consistency of output
            int tmpNumCols = data.split("\t").length;
            if (allNumCols < 0) {
                allNumCols = tmpNumCols;
            } else {
                assert tmpNumCols == allNumCols;
            }
        }
    }
    writer.flush();
    writer.close();

    return allNumCols;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:33,代码来源:CombinedFeatureSource.java

示例14: query

import htsjdk.tribble.Feature; //导入依赖的package包/类
public CloseableTribbleIterator query(String chr, int start, int end) throws IOException {

            int dasStart = start + 1;
            int dasEnd = end;

            if (isValid && !chr.equals("All")) {
                WaitCursorManager.CursorToken token = WaitCursorManager.showWaitCursor();
                try {
                    groupFeatureCache.clear();
                    List<Feature> features = readFeatures(chr, dasStart, dasEnd);
                    if (features.size() < 1) {
                        return EMPTY__ITERATOR;
                    }
                    return new WrappedIterator(features.iterator());
                } finally {
                    groupFeatureCache.clear();
                    WaitCursorManager.removeWaitCursor(token);
                }
            }
            return EMPTY__ITERATOR;
        }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:22,代码来源:DASFeatureSource.java

示例15: parseTree

import htsjdk.tribble.Feature; //导入依赖的package包/类
private List<Feature> parseTree(TreeWalker walker,
                                String tag,
                                String chr,
                                List<Feature> features) {

    Node parent = walker.getCurrentNode();
    Element n = (Element) walker.firstChild();
    while (n != null) {
        if (n.getTagName().equalsIgnoreCase(tag)) {
            Feature f = getFeature(walker, chr);
            if (f != null) {
                features.add(f);
            }

            n = (Element) walker.nextSibling();
            continue;
        }
        parseTree(walker, tag, chr, features);
        n = (Element) walker.nextSibling();
    }
    walker.setCurrentNode(parent);
    return features;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:DASFeatureSource.java


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