本文整理汇总了Java中htsjdk.tribble.FeatureCodec类的典型用法代码示例。如果您正苦于以下问题:Java FeatureCodec类的具体用法?Java FeatureCodec怎么用?Java FeatureCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureCodec类属于htsjdk.tribble包,在下文中一共展示了FeatureCodec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSort
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
public void testSort(File infile, final FeatureCodec codec, final int expectedLines, final int maxMemory)
throws IOException {
File ofile = new File(
infile + (NgbFileUtils.isGzCompressed(infile.getName()) ? ".sorted.gz" : ".sorted")
);
ofile.deleteOnExit();
FeatureFileSortRequest request = new FeatureFileSortRequest();
request.setOriginalFilePath(infile.getAbsolutePath());
request.setSortedFilePath(ofile.getAbsolutePath());
request.setMaxMemory(maxMemory);
toolsManager.sortFeatureFile(request);
int outLines = checkFileSorted(ofile, codec);
if(expectedLines != 0){
assertEquals(expectedLines, outLines);
}
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:22,代码来源:SortTest.java
示例2: checkFileSorted
import htsjdk.tribble.FeatureCodec; //导入依赖的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
示例3: doInBackground
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@Override
protected Index doInBackground() throws Exception {
int binSize = IgvTools.LINEAR_BIN_SIZE;
FeatureCodec codec = CodecFactory.getCodec(file.getAbsolutePath(), GenomeManager.getInstance().getCurrentGenome());
if (codec != null) {
try {
Index index = IndexFactory.createLinearIndex(file, codec, binSize);
if (index != null) {
IgvTools.writeTribbleIndex(index, idxFile.getAbsolutePath());
}
return index;
} catch (TribbleException.MalformedFeatureFile e) {
StringBuffer buf = new StringBuffer();
buf.append("<html>Files must be sorted by start position prior to indexing.<br>");
buf.append(e.getMessage());
buf.append("<br><br>Note: igvtools can be used to sort the file, select \"File > Run igvtools...\".");
MessageUtils.showMessage(buf.toString());
}
} else {
throw new DataLoadException("Unknown File Type", file.getAbsolutePath());
}
return null;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:IndexCreatorDialog.java
示例4: doWork
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@Override
protected Object doWork() {
final FeatureCodec<? extends Feature, ?> codec = FeatureManager.getCodecForFile(inputBedFile);
final Class<? extends Feature> featureType = codec.getFeatureType();
if (BEDFeature.class.isAssignableFrom(featureType)) {
final FeatureDataSource<? extends BEDFeature> source = new FeatureDataSource<>(inputBedFile);
try {
final List<Target> targets = StreamSupport.stream(source.spliterator(), false).map(ConvertBedToTargetFile::createTargetFromBEDFeature)
.collect(Collectors.toList());
TargetWriter.writeTargetsToFile(outFile, targets);
} catch (final TribbleException e) {
throw new UserException.BadInput(String.format("'%s' has a .bed extension but does not seem to be a valid BED file.", inputBedFile.getAbsolutePath()));
}
} else {
throw new UserException.BadInput(String.format("'%s' does not seem to be a BED file.", inputBedFile.getAbsolutePath()));
}
return "SUCCESS";
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:19,代码来源:ConvertBedToTargetFile.java
示例5: getCandidateCodecsForFile
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* Returns a List of all codecs in DISCOVERED_CODECS that claim to be able to decode the specified file
* according to their {@link FeatureCodec#canDecode(String)} methods.
*
* @param featureFile file for which to find potential codecs
* @return A List of all codecs in DISCOVERED_CODECS for which {@link FeatureCodec#canDecode(String)} returns true on the specified file
*/
private static List<FeatureCodec<? extends Feature, ?>> getCandidateCodecsForFile( final Path featureFile ) {
final List<FeatureCodec<? extends Feature, ?>> candidateCodecs = new ArrayList<>();
for ( final Class<?> codecClass : DISCOVERED_CODECS ) {
try {
final FeatureCodec<? extends Feature, ?> codec = (FeatureCodec<? extends Feature, ?>)codecClass.newInstance();
if ( codec.canDecode(featureFile.toAbsolutePath().toUri().toString()) ) {
candidateCodecs.add(codec);
}
}
catch ( InstantiationException | IllegalAccessException e ) {
throw new GATKException("Unable to automatically instantiate codec " + codecClass.getName());
}
}
return candidateCodecs;
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:25,代码来源:FeatureManager.java
示例6: verifyFileType
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
private void verifyFileType(
final File resultVCFFile,
final String outputExtension) {
final FeatureCodec<? extends Feature, ?> featureCodec = FeatureManager.getCodecForFile(resultVCFFile);
if (outputExtension.equals(".vcf") ||
outputExtension.equals(".vcf.bgz") ||
outputExtension.equals(".vcf.gz") ||
outputExtension.equals(".tmp"))
{
Assert.assertEquals(featureCodec.getClass(), VCFCodec.class,
"Wrong codec selected for file " + resultVCFFile.getAbsolutePath());
}
else if (outputExtension.equals(".bcf")) {
Assert.assertEquals(featureCodec.getClass(), BCF2Codec.class,
"Wrong codec selected for file " + resultVCFFile.getAbsolutePath());
}
else {
throw new IllegalArgumentException("Unknown file extension in createVCFWriter test validation");
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:GATKVariantContextUtilsUnitTest.java
示例7: getCodecForFile
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* Utility method that determines the correct codec to use to read Features from the provided file,
* optionally considering only codecs that produce a particular type of Feature.
*
* Codecs MUST correctly implement the {@link FeatureCodec#canDecode(String)} method
* in order to be considered as candidates for decoding the file, and must produce
* Features of the specified type if featureType is non-null.
*
* Throws an exception if no suitable codecs are found (this is a user error, since the file is of
* an unsupported format), or if more than one codec claims to be able to decode the file (this is
* a configuration error on the codec authors' part).
*
* @param featurePath Path for which to find the right codec
* @param featureType If specified, consider only codecs that produce Features of this type. May be null,
* in which case all codecs are considered.
* @return the codec suitable for decoding the provided file
*/
public static FeatureCodec<? extends Feature, ?> getCodecForFile( final Path featurePath, final Class<? extends Feature> featureType ) {
// Make sure Path exists/is readable
if ( ! Files.isReadable(featurePath) ) {
throw new UserException.CouldNotReadInputFile(featurePath);
}
// Gather all discovered codecs that claim to be able to decode the given file according to their
// canDecode() methods
final List<FeatureCodec<? extends Feature, ?>> candidateCodecs = getCandidateCodecsForFile(featurePath);
// If no codecs can handle the file, it's a user error (the user provided a file in an unsupported format)
if ( candidateCodecs.isEmpty() ) {
throw new UserException.NoSuitableCodecs(featurePath);
}
// If featureType was specified, subset to only codecs that produce the requested type of Feature,
// and throw an error if there are no such codecs.
if ( featureType != null ) {
final List<String> discoveredCodecsFeatureTypes = candidateCodecs.stream().map(codec -> codec.getFeatureType().getSimpleName()).collect(Collectors.toList());
candidateCodecs.removeIf(codec -> ! featureType.isAssignableFrom(codec.getFeatureType()));
if ( candidateCodecs.isEmpty() ) {
throw new UserException.WrongFeatureType(featurePath, featureType, discoveredCodecsFeatureTypes);
}
}
// If we still have multiple candidate codecs, it's a configuration error on the part of the codec authors
if ( candidateCodecs.size() > 1 ) {
final StringBuilder multiCodecMatches = new StringBuilder();
for ( FeatureCodec<? extends Feature, ?> candidateCodec : candidateCodecs ) {
multiCodecMatches.append(candidateCodec.getClass().getCanonicalName());
multiCodecMatches.append(' ');
}
throw new GATKException("Multiple codecs found able to decode file " + featurePath.toAbsolutePath().toUri() +
". This indicates a misconfiguration on the part of the codec authors. " +
"Matching codecs are: " + multiCodecMatches.toString());
}
final FeatureCodec<? extends Feature, ?> selectedCodec = candidateCodecs.get(0);
logger.info("Using codec " + selectedCodec.getClass().getSimpleName() + " to read file " + featurePath.toAbsolutePath().toUri());
return selectedCodec;
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:60,代码来源:FeatureManager.java
示例8: FeatureIterator
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* @param inputFile The file from which to read. Stream for reading is opened on construction.
* @param codec feature codec, of features, that iterator should handle
*/
public FeatureIterator(final File inputFile, final FeatureCodec<T, S> codec) {
this.codec = codec;
this.inputFile = inputFile;
final FeatureCodecHeader header = readHeader();
source = (S) codec.makeIndexableSourceFromStream(initStream(inputFile, header.getHeaderEnd()));
readNextFeature();
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:12,代码来源:FeatureIterator.java
示例9: FeatureIterator
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* @param inputFile The file from which to read. Stream for reading is opened on construction.
* @param codec
*/
public FeatureIterator(final File inputFile, final FeatureCodec<F, S> codec) {
this.codec = codec;
this.inputFile = inputFile;
final FeatureCodecHeader header = readHeader();
source =
(S) makeIndexableSourceFromStream(initStream(inputFile, header.getHeaderEnd()));
readNextFeature();
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:13,代码来源:IndexUtils.java
示例10: getFromTable
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* @param table
* @return a SQLCodecSource, or null if no appropriate codec found
*/
public static SQLCodecSource getFromTable(DBProfile.DBTable table) {
FeatureCodec codec = CodecFactory.getCodec("." + table.getFormat(), GenomeManager.getInstance().getCurrentGenome());
if (codec != null && codec instanceof AsciiFeatureCodec) {
return new SQLCodecSource(table, (AsciiFeatureCodec) codec);
}
return null;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:12,代码来源:SQLCodecSource.java
示例11: getInstanceFor
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* Return an parser instance appropriate the the file type. Currently the filename
* is used to determine file type, this is fragile obviously but what is the alternative?
*/
public static FeatureParser getInstanceFor(ResourceLocator locator, Genome genome) {
FeatureCodec codec = CodecFactory.getCodec(locator, genome);
if (codec != null && codec instanceof AsciiFeatureCodec) {
return new FeatureCodecParser((AsciiFeatureCodec) codec, genome);
} else {
return null;
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:13,代码来源:AbstractFeatureParser.java
示例12: insertFeaturesFromFile
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
*
* @param collection
* @param path
* @return The number of features inserted
*/
static int insertFeaturesFromFile(DBCollection collection, String path) {
FeatureCodec codec = CodecFactory.getCodec(path, GenomeManager.getInstance().getCurrentGenome());
if (codec != null) {
AbstractFeatureReader<Feature, ?> bfs = AbstractFeatureReader.getFeatureReader(path, codec, false);
Iterable<Feature> iter = null;
try {
iter = bfs.iterator();
} catch (IOException ex) {
log.error(ex.getMessage(), ex);
throw new RuntimeException("Error reading file: " + path, ex);
}
int count = 0;
for (Feature feat : iter) {
String err = saveFeature(collection, DBFeature.create(feat));
if(err == null){
count += 1;
}else{
log.error("Error inserting feature: " + err);
}
}
return count;
} else {
throw new RuntimeException("Cannot load features from file of this type");
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:35,代码来源:MongoCollabPlugin.java
示例13: createTribbleIndex
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
/**
* Create a tribble style index.
*
* @param ifile
* @param outputFile
* @param indexType
* @param binSize
* @throws IOException
*/
private void createTribbleIndex(String ifile, File outputFile, int indexType, int binSize, FeatureCodec codec) throws IOException {
File inputFile = new File(ifile);
AbstractIndex idx = null;
if (indexType == LINEAR_INDEX) {
idx = IndexFactory.createLinearIndex(inputFile, codec, binSize);
} else {
idx = IndexFactory.createIntervalIndex(inputFile, codec, binSize);
}
if (idx != null) {
// Must scan mutation files for sample names
if (codec instanceof MUTCodec) {
Collection<String> sampleNames = getSampleNames(ifile, (MUTCodec) codec);
StringBuffer buf = new StringBuffer();
for (String sn : sampleNames) {
buf.append(sn);
buf.append(",");
}
idx.addProperty("samples", buf.toString());
}
String idxFile;
if (outputFile != null) {
idxFile = outputFile.getAbsolutePath();
} else {
idxFile = ifile + ".idx";
}
writeTribbleIndex(idx, idxFile);
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:43,代码来源:IgvTools.java
示例14: getCodecForVariantSource
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static FeatureCodec<VariantContext, ?> getCodecForVariantSource( final String variantSource ) {
final FeatureCodec<? extends Feature, ?> codec = FeatureManager.getCodecForFile(new File(variantSource));
if ( !VariantContext.class.isAssignableFrom(codec.getFeatureType()) ) {
throw new UserException(variantSource + " is not in a format that produces VariantContexts");
}
return (FeatureCodec<VariantContext, ?>)codec;
}
开发者ID:broadinstitute,项目名称:gatk-dataflow,代码行数:9,代码来源:VariantsDataflowSource.java
示例15: initializeDrivingFeatures
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void initializeDrivingFeatures() {
final File drivingFile = getDrivingFeatureFile();
final FeatureCodec<? extends Feature, ?> codec = FeatureManager.getCodecForFile(drivingFile);
if (isAcceptableFeatureType(codec.getFeatureType())) {
drivingFeatures = new FeatureDataSource<>(new FeatureInput<>(drivingFile.getAbsolutePath()), FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, null, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, referenceArguments.getReferencePath());
final FeatureInput<F> drivingFeaturesInput = new FeatureInput<>(drivingFile.getAbsolutePath(), "drivingFeatureFile");
features.addToFeatureSources(0, drivingFeaturesInput, codec.getFeatureType(), cloudPrefetchBuffer, cloudIndexPrefetchBuffer,
referenceArguments.getReferencePath());
} else {
throw new UserException("File " + drivingFile + " contains features of the wrong type.");
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:15,代码来源:FeatureWalker.java
示例16: ProgressReportingDelegatingCodec
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
public ProgressReportingDelegatingCodec(final FeatureCodec<A, B> delegatee, final double secondsBetweenUpdates){
if ( secondsBetweenUpdates <= 0.0 ) {
throw new IllegalArgumentException("secondsBetweenUpdates must be > 0.0");
}
this.delegatee = delegatee;
this.pm = new ProgressMeter(secondsBetweenUpdates);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:8,代码来源:ProgressReportingDelegatingCodec.java
示例17: getVariantFeatureInputWithCachedCodec
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private FeatureInput<VariantContext> getVariantFeatureInputWithCachedCodec() {
final File inputVCFFile = new File(FEATURE_INPUT_TEST_DIRECTORY, "minimal_vcf4_file.vcf");
final FeatureInput<VariantContext> featureInput = new FeatureInput<>(inputVCFFile.getAbsolutePath());
Assert.assertNull(featureInput.getFeatureCodecClass());
final FeatureCodec<? extends Feature, ?> codec = FeatureManager.getCodecForFile(new File(featureInput.getFeaturePath()));
featureInput.setFeatureCodecClass((Class<FeatureCodec<VariantContext, ?>>)codec.getClass());
return featureInput;
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:12,代码来源:FeatureInputUnitTest.java
示例18: testDetectCorrectFileFormat
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
@Test(dataProvider = "DetectCorrectFileFormatTestData")
public void testDetectCorrectFileFormat( final File file, final Class<? extends FeatureCodec<? extends Feature, ?>> expectedCodecClass ) throws Exception {
Assert.assertEquals(FeatureManager.getCodecForFile(file).getClass(), expectedCodecClass,
"Wrong codec selected for file " + file.getAbsolutePath());
// We should also get the correct codec if we pass in the explicit expected Feature type to getCodecForFile()
@SuppressWarnings("unchecked")
final Class<? extends Feature> expectedCodecFeatureType = expectedCodecClass.newInstance().getFeatureType();
Assert.assertEquals(FeatureManager.getCodecForFile(file, expectedCodecFeatureType).getClass(), expectedCodecClass,
"Wrong codec selected for file " + file.getAbsolutePath() + " after subsetting to the expected Feature type");
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:12,代码来源:FeatureManagerUnitTest.java
示例19: getNumNonNBases
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
public long getNumNonNBases(final File regions) throws IOException {
long count = 0;
final FeatureCodec<BEDFeature, LineIterator> bedCodec = new BEDCodec(BEDCodec.StartOffset.ONE);
final LineIterator lineIterator = new AsciiLineReaderIterator(new AsciiLineReader(new FileInputStream(regions)));
while (lineIterator.hasNext()) {
final BEDFeature bedFeature = bedCodec.decode(lineIterator);
count += data.get(new ChrString(bedFeature.getContig())).getNumNonNBases(bedFeature.getStart(), bedFeature.getEnd());
}
return count;
}
开发者ID:bioinform,项目名称:varsim,代码行数:13,代码来源:SimpleReference.java
示例20: CachedFeatureReader
import htsjdk.tribble.FeatureCodec; //导入依赖的package包/类
public CachedFeatureReader(List<T> cachedFeatures, FeatureCodec<T, S> codec) {
super("", codec);
this.cachedFeatures = cachedFeatures;
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:5,代码来源:CachedFeatureReader.java
注:本文中的htsjdk.tribble.FeatureCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论