本文整理汇总了Java中htsjdk.tribble.Tribble类的典型用法代码示例。如果您正苦于以下问题:Java Tribble类的具体用法?Java Tribble怎么用?Java Tribble使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tribble类属于htsjdk.tribble包,在下文中一共展示了Tribble类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertFile
import htsjdk.tribble.Tribble; //导入依赖的package包/类
private File convertFile(final File input, final String prefix, final String format) {
final File outputFile;
try {
outputFile = File.createTempFile(prefix, format);
} catch (final IOException ioe) {
throw new PicardException("Unable to create temp file!");
}
outputFile.deleteOnExit();
new File(outputFile.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION).deleteOnExit();
final List<String> args = new ArrayList<String>(Arrays.asList(
"INPUT=" + input.getAbsolutePath(),
"OUTPUT=" + outputFile.getAbsolutePath()
));
if (VCF_GZ.equals(format)) {
args.add("CREATE_INDEX=false");
}
if (input.getName().endsWith(VCF_GZ)) {
args.add("REQUIRE_INDEX=false");
}
Assert.assertEquals(runPicardCommandLine(args), 0);
return outputFile;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:VcfFormatConverterTest.java
示例2: loadTribbleIndex
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* Load a Tribble .idx index from disk, checking for out of date indexes and old versions
* @return an Index, or null if we're unable to load
*/
public static Index loadTribbleIndex(final File featureFile) {
Utils.nonNull(featureFile);
final File indexFile = Tribble.indexFile(featureFile);
if (! indexFile.canRead()) {
return null;
}
logger.debug("Loading Tribble index from disk for file " + featureFile);
try {
final Index index = IndexFactory.loadIndex(indexFile.getAbsolutePath());
checkIndexVersionAndModificationTime(featureFile, indexFile, index);
return index;
} catch (final RuntimeException e){
return null;
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:20,代码来源:IndexUtils.java
示例3: createTempFile
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* Creates a temp file that will be deleted on exit
*
* This will also mark the corresponding Tribble/Tabix/BAM indices matching the temp file for deletion.
* @param name Prefix of the file.
* @param extension Extension to concat to the end of the file.
* @return A file in the temporary directory starting with name, ending with extension, which will be deleted after the program exits.
*/
public static File createTempFile(String name, String extension) {
try {
if ( !extension.startsWith(".") ) {
extension = "." + extension;
}
final File file = File.createTempFile(name, extension);
file.deleteOnExit();
// Mark corresponding indices for deletion on exit as well just in case an index is created for the temp file:
new File(file.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION).deleteOnExit();
new File(file.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION).deleteOnExit();
new File(file.getAbsolutePath() + ".bai").deleteOnExit();
new File(file.getAbsolutePath() + ".md5").deleteOnExit();
new File(file.getAbsolutePath().replaceAll(extension + "$", ".bai")).deleteOnExit();
return file;
} catch (IOException ex) {
throw new GATKException("Cannot create temp file: " + ex.getMessage(), ex);
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:31,代码来源:IOUtils.java
示例4: testVCFIndex_inferredName
import htsjdk.tribble.Tribble; //导入依赖的package包/类
@Test
public void testVCFIndex_inferredName() {
final File ORIG_FILE = getTestFile("test_variants_for_index.vcf");
final String[] args = {
"--feature-file" , ORIG_FILE.getAbsolutePath(),
};
final Object res = this.runCommandLine(args);
final File tribbleIndex = Tribble.indexFile(ORIG_FILE);
Assert.assertEquals(res, tribbleIndex.getAbsolutePath());
tribbleIndex.deleteOnExit();
final Index index = IndexFactory.loadIndex(res.toString());
Assert.assertTrue(index instanceof LinearIndex);
Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1", "2", "3", "4"));
checkIndex(index, Arrays.asList("1", "2", "3", "4"));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:18,代码来源:IndexFeatureFileIntegrationTest.java
示例5: EvsXmlFile
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* tribble access to XML file generated with evsDumpXml
* @param xmlFile
* @throws IOException
*/
public EvsXmlFile(File xmlFile) throws IOException
{
File idxFile = Tribble.indexFile(xmlFile);
SnpDataCodec tribbleCodec=new SnpDataCodec();
if(idxFile.exists() && idxFile.lastModified()>=xmlFile.lastModified())
{
tribbleIndex=IndexFactory.loadIndex(idxFile.getPath());
}
else
{
tribbleIndex=IndexFactory.createLinearIndex(xmlFile, tribbleCodec);
}
this.tribble =
new TribbleIndexedFeatureReader<>(
xmlFile.getPath(),
tribbleCodec,
tribbleIndex
);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:27,代码来源:EvsXmlFile.java
示例6: TribbleReader
import htsjdk.tribble.Tribble; //导入依赖的package包/类
TribbleReader(final File bedFile) throws IOException
{
final File indexFile = Tribble.indexFile(bedFile);
if(indexFile.exists())
{
LOG.info("loading tribble index in memory for "+ bedFile);
this.tribbleIndex=IndexFactory.loadIndex(indexFile.getPath());
}
else
{
LOG.info("creating index from file "+bedFile+" indexFile:"+indexFile);
this.tribbleIndex=IndexFactory.createLinearIndex(bedFile, this.bedCodec);
}
this.reader = AbstractFeatureReader.getFeatureReader(
bedFile.getPath(),
this.bedCodec,
this.tribbleIndex
);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:20,代码来源:IndexedBedReader.java
示例7: getTempFilePath
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* Get a temporary file path based on the prefix and extension provided.
* This file (and possible indexes associated with it) will be scheduled for deletion on shutdown
*
* @param prefix a prefix for the file name
* for remote paths this should be a valid URI to root the temporary file in (ie. gcs://hellbender/staging/)
* there is no guarantee that this will be used as the root of the tmp file name, a local prefix may be placed in the tmp folder for example
* @param extension and extension for the temporary file path, the resulting path will end in this
* @return a path to use as a temporary file, on remote file systems which don't support an atomic tmp file reservation a path is chosen with a long randomized name
*
*/
public static String getTempFilePath(String prefix, String extension){
if (isCloudStorageUrl(prefix) || (isHadoopUrl(prefix))){
final String path = randomRemotePath(prefix, "", extension);
deleteOnExit(path);
deleteOnExit(path + Tribble.STANDARD_INDEX_EXTENSION);
deleteOnExit(path + TabixUtils.STANDARD_INDEX_EXTENSION);
deleteOnExit(path + ".bai");
deleteOnExit(path + ".md5");
deleteOnExit(path.replaceAll(extension + "$", ".bai")); //if path ends with extension, replace it with .bai
return path;
} else {
try {
final File file = File.createTempFile(prefix, extension);
file.deleteOnExit();
// Mark corresponding indices for deletion on exit as well just in case an index is created for the temp file:
new File(file.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION).deleteOnExit();
new File(file.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION).deleteOnExit();
new File(file.getAbsolutePath() + ".bai").deleteOnExit();
new File(file.getAbsolutePath() + ".md5").deleteOnExit();
new File(file.getAbsolutePath().replaceAll(extension + "$", ".bai")).deleteOnExit();
return file.getAbsolutePath();
} catch (IOException ex) {
throw new UserException("Cannot create temp file: " + ex.getMessage(), ex);
}
}
}
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:40,代码来源:BucketUtils.java
示例8: indexFile
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* @param locator
* @return locator.getIndexPath() if not null, otherwise
* {@link #appendToPath(ResourceLocator, String)}
* where the second argument is .idx or tbi, depending on the resource
*/
public static String indexFile(ResourceLocator locator) {
if (locator.getIndexPath() != null) {
return locator.getIndexPath();
}
String indexExtension = (locator.getURLPath().toLowerCase().endsWith(".gz") || locator.getPath().toLowerCase().endsWith(".bgz")) ? ".tbi" : Tribble.STANDARD_INDEX_EXTENSION;
return appendToPath(locator, indexExtension);
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:14,代码来源:ResourceLocator.java
示例9: testIndexIsCreated
import htsjdk.tribble.Tribble; //导入依赖的package包/类
@Test
public void testIndexIsCreated(){
final File output = createTempFile("test", ".vcf");
final File index = new File(output.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION);
Assert.assertFalse(index.exists());
final ArgumentsBuilder args = new ArgumentsBuilder()
.addVCF(getTestFile(BASE_PAIR_GVCF))
.addOutput(output)
.addReference(new File(b37_reference_20_21))
.addArgument(StandardArgumentDefinitions.CREATE_OUTPUT_VARIANT_INDEX_LONG_NAME, "true");
runCommandLine(args);
Assert.assertTrue(index.exists());
}
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:15,代码来源:GenotypeGVCFsIntegrationTest.java
示例10: getTempFilePath
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* Get a temporary file path based on the prefix and extension provided.
* This file (and possible indexes associated with it) will be scheduled for deletion on shutdown
*
* @param prefix a prefix for the file name
* for remote paths this should be a valid URI to root the temporary file in (ie. gcs://hellbender/staging/)
* there is no guarantee that this will be used as the root of the tmp file name, a local prefix may be placed in the tmp folder for example
* @param extension and extension for the temporary file path, the resulting path will end in this
* @return a path to use as a temporary file, on remote file systems which don't support an atomic tmp file reservation a path is chosen with a long randomized name
*
*/
public static String getTempFilePath(String prefix, String extension){
if (isCloudStorageUrl(prefix) || (isHadoopUrl(prefix))){
final String path = randomRemotePath(prefix, "", extension);
deleteOnExit(path);
deleteOnExit(path + Tribble.STANDARD_INDEX_EXTENSION);
deleteOnExit(path + TabixUtils.STANDARD_INDEX_EXTENSION);
deleteOnExit(path + ".bai");
deleteOnExit(path + ".md5");
deleteOnExit(path.replaceAll(extension + "$", ".bai")); //if path ends with extension, replace it with .bai
return path;
} else {
return IOUtils.createTempFile(prefix, extension).getAbsolutePath();
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:26,代码来源:BucketUtils.java
示例11: testIndexingAndIndexCreation
import htsjdk.tribble.Tribble; //导入依赖的package包/类
@Test(dataProvider = "testIndexingProvider")
public void testIndexingAndIndexCreation( final String fileName,
final String contig,
final int start,
final int end,
final int numExpectedGenes ) throws IOException {
final GencodeGtfCodec codec = new GencodeGtfCodec();
// Create a temp dir:
final File tmpDir = createTempDir("testIndexingAndIndexCreation_" + start + "_" + end);
// Create a copy of our index file:
final File originalTestFile = new File(fileName);
final File testFile = new File(tmpDir.getAbsolutePath() + File.separator + originalTestFile.getName());
// Copy our file to the tmp dir:
Files.copy(originalTestFile.toPath(), testFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
// Create our Index:
final File indexFile = Tribble.indexFile(testFile);
final Index index = IndexFactory.createDynamicIndex(testFile, codec, IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME);
index.write(indexFile);
// Make sure it works:
testIndexHelper(contig, start, end, numExpectedGenes, testFile);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:28,代码来源:GencodeGtfCodecUnitTest.java
示例12: TribbleVcfFileReader
import htsjdk.tribble.Tribble; //导入依赖的package包/类
public TribbleVcfFileReader(final File vcf) throws IOException
{
this.source=vcf;
if(vcf==null) throw new NullPointerException("vcf file==null");
IOUtil.assertFileIsReadable(vcf);
this.tribbleCodec = VCFUtils.createAsciiFeatureCodec();
File indexFile=Tribble.indexFile(this.source);
if(indexFile.exists() && indexFile.lastModified()> vcf.lastModified())
{
LOG.info("loading index in memory for "+this.source+" index="+indexFile);
this.tribbleIndex=IndexFactory.loadIndex(indexFile.getPath());
}
else
{
LOG.info("create index from file "+this.source);
this.tribbleIndex=IndexFactory.createLinearIndex(vcf, tribbleCodec);
}
this.reader =
AbstractFeatureReader.getFeatureReader(
vcf.getPath(),
this.tribbleCodec,
this.tribbleIndex
);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:28,代码来源:TribbleVcfFileReader.java
示例13: isTribbleVcfFile
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/** returns true if file ends with .vcf and a .idx file is associated */
public static boolean isTribbleVcfFile(File f)
{
if(!isVcfFile(f)) return false;
String filename=f.getName();
if(!filename.endsWith(".vcf")) return false;
File index=new File(f.getParentFile(),
filename+ Tribble.STANDARD_INDEX_EXTENSION
);
return index.exists() && index.isFile();
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:12,代码来源:VCFUtils.java
示例14: testOutputFileArgumentVariations
import htsjdk.tribble.Tribble; //导入依赖的package包/类
@Test(dataProvider = "outputFileVariations")
public void testOutputFileArgumentVariations(
final boolean createBamoutIndex,
final boolean createBamoutMD5,
final boolean createVCFOutIndex,
final boolean createVCFOutMD5) {
Utils.resetRandomGenerator();
// run on small interval to test index/md5 outputs
final String testInterval = "20:10000000-10001000";
final File vcfOutput = createTempFile("testOutputFileArgumentVariations", ".vcf");
final File bamOutput = createTempFile("testOutputFileArgumentVariations", ".bam");
ArgumentsBuilder argBuilder = new ArgumentsBuilder();
argBuilder.addInput(new File(NA12878_20_21_WGS_bam));
argBuilder.addReference(new File(b37_reference_20_21));
argBuilder.addOutput(new File(vcfOutput.getAbsolutePath()));
argBuilder.addArgument("L", testInterval);
argBuilder.addArgument("bamout", bamOutput.getAbsolutePath());
argBuilder.addArgument("pairHMM", "AVX_LOGLESS_CACHING");
argBuilder.addBooleanArgument(StandardArgumentDefinitions.CREATE_OUTPUT_BAM_INDEX_LONG_NAME, createBamoutIndex);
argBuilder.addBooleanArgument(StandardArgumentDefinitions.CREATE_OUTPUT_BAM_MD5_LONG_NAME, createBamoutMD5);
argBuilder.addBooleanArgument(StandardArgumentDefinitions.CREATE_OUTPUT_VARIANT_INDEX_LONG_NAME, createVCFOutIndex);
argBuilder.addBooleanArgument(StandardArgumentDefinitions.CREATE_OUTPUT_VARIANT_MD5_LONG_NAME, createVCFOutMD5);
runCommandLine(argBuilder.getArgsArray());
Assert.assertTrue(vcfOutput.exists(), "No VCF output file was created");
// validate vcfout companion files
final File vcfOutFileIndex = new File(vcfOutput.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION);
final File vcfOutFileMD5 = new File(vcfOutput.getAbsolutePath() + ".md5");
Assert.assertEquals(vcfOutFileIndex.exists(), createVCFOutIndex, "The index file argument was not honored");
Assert.assertEquals(vcfOutFileMD5.exists(), createVCFOutMD5, "The md5 file argument was not honored");
// validate bamout companion files
if (createBamoutIndex) {
Assert.assertNotNull(SamFiles.findIndex(bamOutput));
} else {
Assert.assertNull(SamFiles.findIndex(bamOutput));
}
final File expectedBamoutMD5File = new File(bamOutput.getAbsolutePath() + ".md5");
Assert.assertEquals(expectedBamoutMD5File.exists(), createBamoutMD5);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:48,代码来源:HaplotypeCallerIntegrationTest.java
示例15: indexExists
import htsjdk.tribble.Tribble; //导入依赖的package包/类
/**
* Determines whether an index file exists for the given vcf file using standard extension suffixes
*
* @param vcf the vcf file to investigate
* @return true if an index file exists, false otherwise
*/
private boolean indexExists(final File vcf) {
return Tribble.indexFile(vcf).exists() || Tribble.tabixIndexFile(vcf).exists();
}
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:GenotypeConcordance.java
注:本文中的htsjdk.tribble.Tribble类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论