本文整理汇总了Java中htsjdk.tribble.FeatureCodec类的典型用法代码示例。如果您正苦于以下问题:Java FeatureCodec类的具体用法?Java FeatureCodec怎么用?Java FeatureCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureCodec类属于htsjdk.tribble包,在下文中一共展示了FeatureCodec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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;
}
示例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";
}
示例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;
}
示例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");
}
}
示例7: 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();
}
示例8: 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();
}
示例9: 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;
}
示例10: 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;
}
}
示例11: 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");
}
}
示例12: 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);
}
}
示例13: 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;
}
示例14: 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.");
}
}
示例15: 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);
}