本文整理汇总了Java中htsjdk.samtools.SamReaderFactory.referenceSequence方法的典型用法代码示例。如果您正苦于以下问题:Java SamReaderFactory.referenceSequence方法的具体用法?Java SamReaderFactory.referenceSequence怎么用?Java SamReaderFactory.referenceSequence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SamReaderFactory
的用法示例。
在下文中一共展示了SamReaderFactory.referenceSequence方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeReads
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/**
* Initialize our source of reads data (or set it to null if no reads argument(s) were provided).
*
* Package-private so that engine classes can access it, but concrete tool child classes cannot.
* May be overridden by traversals that require custom initialization of the reads data source.
*/
void initializeReads() {
if (! readArguments.getReadFiles().isEmpty()) {
SamReaderFactory factory = SamReaderFactory.makeDefault().validationStringency(readArguments.getReadValidationStringency());
if (hasReference()) { // pass in reference if available, because CRAM files need it
factory = factory.referenceSequence(referenceArguments.getReferencePath());
}
else if (hasCramInput()) {
throw new UserException.MissingReference("A reference file is required when using CRAM files.");
}
if(bamIndexCachingShouldBeEnabled()) {
factory = factory.enable(SamReaderFactory.Option.CACHE_FILE_BASED_INDEXES);
}
reads = new ReadsDataSource(readArguments.getReadPaths(), readArguments.getReadIndexPaths(), factory, cloudPrefetchBuffer,
(cloudIndexPrefetchBuffer < 0 ? cloudPrefetchBuffer : cloudIndexPrefetchBuffer));
}
else {
reads = null;
}
}
示例2: getDuplicateCountForBam
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
private static int getDuplicateCountForBam(final File bam, final File referenceFile) throws IOException {
int duplicateCount = 0;
final SamReaderFactory factory = SamReaderFactory.makeDefault();
if(referenceFile != null) {
factory.referenceSequence(referenceFile);
}
try ( final SamReader reader = factory.open(bam) ) {
for ( SAMRecord read : reader ) {
if ( read.getDuplicateReadFlag() ) {
++duplicateCount;
}
}
}
return duplicateCount;
}
示例3: testReadFilters
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Test(dataProvider = "readFilterTestData")
public void testReadFilters(
final String input,
final String reference,
final String extOut,
final List<String> inputArgs,
final int expectedCount) throws IOException
{
final File outFile = createTempFile("testReadFilter", extOut);
final ArgumentsBuilder args = new ArgumentsBuilder();
args.add("-I"); args.add(new File(TEST_DATA_DIR, input).getAbsolutePath());
args.add("-O"); args.add(outFile.getAbsolutePath());
if ( reference != null ) {
args.add("-R"); args.add(new File(TEST_DATA_DIR, reference).getAbsolutePath());
}
for (final String filter : inputArgs) {
args.add(filter);
}
runCommandLine(args);
SamReaderFactory factory = SamReaderFactory.makeDefault();
if (reference != null) {
factory = factory.referenceSequence(new File(TEST_DATA_DIR, reference));
}
int count = 0;
try (final SamReader reader = factory.open(outFile)) {
Iterator<SAMRecord> it = reader.iterator();
while (it.hasNext()) {
SAMRecord rec = it.next();
count++;
}
}
Assert.assertEquals(count, expectedCount);
}
示例4: testReadFilters
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Test(dataProviderClass = org.broadinstitute.hellbender.tools.PrintReadsIntegrationTest.class, dataProvider = "readFilterTestData", groups = "spark")
public void testReadFilters(
final String input,
final String reference,
final String extOut,
final List<String> inputArgs,
final int expectedCount) throws IOException
{
final File outFile = createTempFile("testReadFilter", extOut);
final ArgumentsBuilder args = new ArgumentsBuilder();
args.add("-I"); args.add(new File(TEST_DATA_DIR, input).getAbsolutePath());
args.add("-O"); args.add(outFile.getAbsolutePath());
if ( reference != null ) {
args.add("-R"); args.add(new File(TEST_DATA_DIR, reference).getAbsolutePath());
}
for (final String filter : inputArgs) {
args.add(filter);
}
runCommandLine(args);
SamReaderFactory factory = SamReaderFactory.makeDefault();
if (reference != null) {
factory = factory.referenceSequence(new File(TEST_DATA_DIR, reference));
}
int count = 0;
try (final SamReader reader = factory.open(outFile)) {
Iterator<SAMRecord> it = reader.iterator();
while (it.hasNext()) {
SAMRecord rec = it.next();
count++;
}
}
Assert.assertEquals(count, expectedCount);
}