本文整理汇总了Java中htsjdk.samtools.SamReaderFactory.makeDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SamReaderFactory.makeDefault方法的具体用法?Java SamReaderFactory.makeDefault怎么用?Java SamReaderFactory.makeDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SamReaderFactory
的用法示例。
在下文中一共展示了SamReaderFactory.makeDefault方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/**
* A method that creates a SamReader object that's passed on to the HTSJDK.
* Each time someone tries to open a SamReader on an URL,
* HTSJDK checks if there's a custom reader factory and if it's there, this method is called.
*
* @param url target file URL
* @return A SamReader object on a specified file URL
*/
@Override
public SamReader open(URL url) {
PerformanceMonitor.start();
AmazonS3URI amazonURI = new AmazonS3URI(url.toString());
S3Client client = new S3Client();
S3InputStreamFactory streamFactory = new S3InputStreamFactory(client);
//download index file if is possible, and then start download .bam file
final Optional<SeekableStream> indexStream;
try {
IndexLoader loader = new IndexLoader(client);
indexStream = loader.loadIndex(amazonURI);
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage() + " failed to download index", e);
}
SeekableStream stream = new S3SeekableStream(amazonURI, client, streamFactory);
SamReaderFactory factory = SamReaderFactory.makeDefault();
SamInputResource inputResource = SamInputResource.of(stream);
indexStream.ifPresent(inputResource::index);
return factory.open(inputResource);
}
示例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: reOpen
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Override
public BamFile reOpen() throws IOException {
final String url=this.getSource();
final SamReaderFactory srf = SamReaderFactory.makeDefault();
srf.validationStringency(ValidationStringency.LENIENT);
final SamInputResource sir;
if(IOUtil.isUrl(url))
{
sir = SamInputResource.of(new URL(url));
if(!this.indexFile.isPresent()) throw new IOException("Boum");
sir.index(this.indexFile.get());
}
else
{
sir = SamInputResource.of(new File(url));
}
final BamFile bf = new BamFile(url,srf.open(sir),this.indexFile);
bf.delete_index_on_close=false;
return bf;
}
示例4: 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);
}
示例5: 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);
}
示例6: ReadReaderFactory
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/** Creates a default factory. */
public ReadReaderFactory() {
this.samFactory = SamReaderFactory.makeDefault();
}
示例7: exec
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Exec
public void exec() throws IOException, CommandArgumentException {
if (filename == null) {
throw new CommandArgumentException("You must specify an input BAM filename!");
}
SamReaderFactory readerFactory = SamReaderFactory.makeDefault();
if (lenient) {
readerFactory.validationStringency(ValidationStringency.LENIENT);
} else if (silent) {
readerFactory.validationStringency(ValidationStringency.SILENT);
}
SamReader reader = null;
String name;
FileChannel channel = null;
if (filename.equals("-")) {
reader = readerFactory.open(SamInputResource.of(System.in));
name = "<stdin>";
} else {
File f = new File(filename);
FileInputStream fis = new FileInputStream(f);
channel = fis.getChannel();
reader = readerFactory.open(SamInputResource.of(fis));
name = f.getName();
}
Set<String> readNames = new HashSet<String>();
Iterator<SAMRecord> it = ProgressUtils.getIterator(name, reader.iterator(), (channel == null)? null : new FileChannelStats(channel), new ProgressMessage<SAMRecord>() {
long i = 0;
@Override
public String msg(SAMRecord current) {
i++;
return i+" "+current.getReadName();
}}, new CloseableFinalizer<SAMRecord>());
System.err.print("Reading file...");
while (it.hasNext()) {
readNames.add(it.next().getReadName());
}
System.err.println(" done");
reader.close();
List<String> readNameList = new ArrayList<String>(readNames);
readNames.clear();
for (int i=1; i<=numberOfSamplings; i++) {
System.err.println("Generating list #"+i+"...");
Random rdm = new Random();
Set<String> keptReads = new HashSet<String>();
int j=0;
while (j<sampleSize) {
int idx = rdm.nextInt(readNameList.size());
if (!keptReads.contains(readNameList.get(idx))) {
keptReads.add(readNameList.get(idx));
j++;
}
}
OutputStream os = new FileOutputStream(outputFilename+"."+i+".txt");
for (String readName: keptReads) {
os.write((readName+"\n").getBytes());
}
os.close();
}
}
示例8: newInstance
import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
public static BamFile newInstance(final File f) throws IOException {
IOUtil.assertFileIsReadable(f);
final SamReaderFactory srf = SamReaderFactory.makeDefault();
srf.validationStringency(ValidationStringency.LENIENT);
return new BamFile(f.getAbsolutePath(),srf.open(f),Optional.empty());
}