本文整理汇总了Java中htsjdk.samtools.BAMIndexer类的典型用法代码示例。如果您正苦于以下问题:Java BAMIndexer类的具体用法?Java BAMIndexer怎么用?Java BAMIndexer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BAMIndexer类属于htsjdk.samtools包,在下文中一共展示了BAMIndexer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createIndex
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
/**
* Create the BAI index.
* @param conf the Hadoop configuration
* @param bamFile the BAM file
* @param indexFile the BAI file
* @throws IOException if an error occurs while creating the index
*/
static void createIndex(final Configuration conf, final Path bamFile,
final Path indexFile) throws IOException {
final InputStream in = FileSystem.get(conf).open(bamFile);
final SamReader reader = SamReaderFactory.makeDefault()
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.validationStringency(ValidationStringency.DEFAULT_STRINGENCY)
.open(SamInputResource.of(in));
final BAMIndexer indexer =
new BAMIndexer(indexFile.getFileSystem(conf).create(indexFile),
reader.getFileHeader());
for (SAMRecord rec : reader) {
indexer.processAlignment(rec);
}
indexer.finish();
}
开发者ID:GenomicParisCentre,项目名称:eoulsan,代码行数:29,代码来源:SAM2BAMHadoopModule.java
示例2: deprecatedCreateIndex
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
private static void deprecatedCreateIndex(File inputBamFile, File outputBamIndexFile) {
// make sure that the default validation strategy for the SamReaderFactory is used here too.
SAMFileReader.setDefaultValidationStringency(SamReaderFactory.makeDefault().validationStringency());
try (SAMFileReader reader = new SAMFileReader(inputBamFile)) {
BAMIndexer indexer = new BAMIndexer(outputBamIndexFile, reader.getFileHeader());
reader.enableFileSource(true);
// create and write the content
for (SAMRecord rec : reader) {
indexer.processAlignment(rec);
}
indexer.finish();
}
}
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:17,代码来源:BamFileUtil.java
示例3: indexBam
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
public void indexBam(File bamFile, File baiFile) {
SAMFileReader.setDefaultValidationStringency(ValidationStringency.SILENT);
final SamReader bam;
// input from a normal file
IOUtil.assertFileIsReadable(bamFile);
bam = SamReaderFactory.makeDefault().referenceSequence(null)
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.open(bamFile);
if (bam.type() != SamReader.Type.BAM_TYPE) {
throw new SAMException("Input file must be bam file, not sam file.");
}
if (!bam.getFileHeader().getSortOrder().equals(SAMFileHeader.SortOrder.coordinate)) {
throw new SAMException("Input bam file must be sorted by coordinate");
}
BAMIndexer.createIndex(bam, baiFile);
CloserUtil.close(bam);
}
开发者ID:chipster,项目名称:chipster,代码行数:23,代码来源:SamBamUtils.java
示例4: doMenuIndexBam
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
/** open index a BAM file */
private void doMenuIndexBam(final Window owner)
{
final FileChooser fc = newFileChooser();
fc.getExtensionFilters().addAll(BamStage.EXTENSION_FILTERS);
final List<File> files = fc.showOpenMultipleDialog(owner);
if(files==null) return;
for(final File file : files)
{
LOG.info("indexing "+file);
updateLastDir(file);
SamReader bam=null;
try
{
final File output= new File(file.getAbsolutePath() + BAMIndex.BAMIndexSuffix);
if(output.exists())
{
throw new IOException("Bam index "+output+" already exists.");
}
bam = SamReaderFactory.makeDefault()
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.validationStringency(ValidationStringency.LENIENT)
.open(file);
;
BAMIndexer.createIndex(bam, output);
final Alert alert = new Alert(AlertType.CONFIRMATION, "Done. ?", ButtonType.OK);
alert.showAndWait();
}
catch(final Exception err)
{
showExceptionDialog(owner, err);
break;
}
finally
{
CloserUtil.close(bam);
}
}
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:40,代码来源:JfxNgs.java
示例5: doWork
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
/**
* Main method for the program. Checks that all input files are present and
* readable and that the output file can be written to. Then iterates through
* all the records generating a BAM Index, then writes the bai file.
*/
protected int doWork() {
try {
inputUrl = new URL(INPUT);
} catch (java.net.MalformedURLException e) {
inputFile = new File(INPUT);
}
// set default output file - input-file.bai
if (OUTPUT == null) {
final String baseFileName;
if (inputUrl != null) {
final String path = inputUrl.getPath();
final int lastSlash = path.lastIndexOf('/');
baseFileName = path.substring(lastSlash + 1, path.length());
} else {
baseFileName = inputFile.getAbsolutePath();
}
if (baseFileName.endsWith(BamFileIoUtils.BAM_FILE_EXTENSION)) {
final int index = baseFileName.lastIndexOf('.');
OUTPUT = new File(baseFileName.substring(0, index) + BAMIndex.BAMIndexSuffix);
} else {
OUTPUT = new File(baseFileName + BAMIndex.BAMIndexSuffix);
}
}
IOUtil.assertFileIsWritable(OUTPUT);
final SamReader bam;
if (inputUrl != null) {
// remote input
bam = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE)
.disable(SamReaderFactory.Option.EAGERLY_DECODE)
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.open(SamInputResource.of(inputUrl));
} else {
// input from a normal file
IOUtil.assertFileIsReadable(inputFile);
bam = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE)
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.open(inputFile);
}
if (bam.type() != SamReader.Type.BAM_TYPE) {
throw new SAMException("Input file must be bam file, not sam file.");
}
if (!bam.getFileHeader().getSortOrder().equals(SAMFileHeader.SortOrder.coordinate)) {
throw new SAMException("Input bam file must be sorted by coordinate");
}
BAMIndexer.createIndex(bam, OUTPUT);
log.info("Successfully wrote bam index file " + OUTPUT);
CloserUtil.close(bam);
return 0;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:67,代码来源:BuildBamIndex.java
示例6: writeBamFile
import htsjdk.samtools.BAMIndexer; //导入依赖的package包/类
public static File writeBamFile(int numPairs, SAMFileHeader.SortOrder sortOrder)
throws IOException {
// file will be both queryname and coordinate sorted, so use one or the other
SAMRecordSetBuilder samRecordSetBuilder = new SAMRecordSetBuilder(true, sortOrder);
for (int i = 0; i < numPairs; i++) {
int chr = 20;
int start1 = (i + 1) * 1000;
int start2 = start1 + 100;
if (i == 5) { // add two unmapped fragments instead of a mapped pair
samRecordSetBuilder.addFrag(String.format("test-read-%03d-1", i), chr, start1,
false, true, null,
null,
-1, false);
samRecordSetBuilder.addFrag(String.format("test-read-%03d-2", i), chr, start2,
false, true, null,
null,
-1, false);
} else {
samRecordSetBuilder.addPair(String.format("test-read-%03d", i), chr, start1,
start2);
}
}
if (numPairs > 0) { // add two unplaced unmapped fragments if non-empty
samRecordSetBuilder.addUnmappedFragment(String.format
("test-read-%03d-unplaced-unmapped", numPairs++));
samRecordSetBuilder.addUnmappedFragment(String.format
("test-read-%03d-unplaced-unmapped", numPairs++));
}
final File bamFile = File.createTempFile("test", ".bam");
bamFile.deleteOnExit();
SAMFileHeader samHeader = samRecordSetBuilder.getHeader();
final SAMFileWriter bamWriter = new SAMFileWriterFactory()
.makeSAMOrBAMWriter(samHeader, true, bamFile);
for (final SAMRecord rec : samRecordSetBuilder.getRecords()) {
bamWriter.addAlignment(rec);
}
bamWriter.close();
// create BAM index
if (sortOrder.equals(SAMFileHeader.SortOrder.coordinate)) {
SamReader samReader = SamReaderFactory.makeDefault()
.enable(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS)
.open(bamFile);
BAMIndexer.createIndex(samReader, new File(bamFile.getAbsolutePath()
.replaceFirst("\\.bam$", BAMIndex.BAMIndexSuffix)));
}
return bamFile;
}
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:51,代码来源:BAMTestUtil.java
注:本文中的htsjdk.samtools.BAMIndexer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论