/** * @return true if contained string is an SRA accession */ public boolean isValid() { return SRAAccession.isValid(acc); }
/** * @return true if contained string is an SRA accession */ public boolean isValid() { return SRAAccession.isValid(acc); }
/** Attempts to detect whether the file is an SRA accessioned file. If SRA support is not available, returns false. */ private boolean isSra(final File sourceFile) { try { // if SRA fails to initialize (the most common reason is a failure to find/load native libraries), // it will throw a subclass of java.lang.Error and here we only catch subclasses of java.lang.Exception // // Note: SRA initialization errors should not be ignored, but rather shown to user return SRAAccession.isValid(sourceFile.getPath()); } catch (final Exception e) { return false; } }
/** Attempts to detect whether the file is an SRA accessioned file. If SRA support is not available, returns false. */ private boolean isSra(final File sourceFile) { try { // if SRA fails to initialize (the most common reason is a failure to find/load native libraries), // it will throw a subclass of java.lang.Error and here we only catch subclasses of java.lang.Exception // // Note: SRA initialization errors should not be ignored, but rather shown to user return SRAAccession.isValid(sourceFile.getPath()); } catch (final Exception e) { return false; } }
@Test(dataProvider = "isValidAccData") public void testIsValidAcc(String accession, boolean isValid) { Assert.assertEquals(isValid, SRAAccession.isValid(accession)); }
/** * @param acc accession */ public SRAIndexedSequenceFile(SRAAccession acc) { this.acc = acc; if (!acc.isValid()) { throw new RuntimeException("Passed an invalid SRA accession into SRA reader: " + acc); } try { run = gov.nih.nlm.ncbi.ngs.NGS.openReadCollection(acc.toString()); sequenceDictionary = loadSequenceDictionary(); } catch (final ErrorMsg e) { throw new RuntimeException(e); } reset(); }
/** * @param acc accession */ public SRAIndexedSequenceFile(SRAAccession acc) { this.acc = acc; if (!acc.isValid()) { throw new RuntimeException("Passed an invalid SRA accession into SRA reader: " + acc); } try { run = gov.nih.nlm.ncbi.ngs.NGS.openReadCollection(acc.toString()); sequenceDictionary = loadSequenceDictionary(); } catch (final ErrorMsg e) { throw new RuntimeException(e); } reset(); }
unpackedReads.add(new SAMReaderID(inputFileName,inputFileNameTags)); else if(SRAAccession.isValid(inputFileName)) { unpackedReads.add(new SAMReaderID(inputFileName,inputFileNameTags));
if (SRAAccession.isValid(fastaFile.getPath())) { return new SRAIndexedSequenceFile(new SRAAccession(fastaFile.getPath()));
public SRAFileReader(final SRAAccession acc) { this.acc = acc; if (!acc.isValid()) { throw new IllegalArgumentException("SRAFileReader: cannot resolve SRA accession '" + acc + "'\n" + "Possible causes are an invalid SRA accession or a connection problem."); } try { run = gov.nih.nlm.ncbi.ngs.NGS.openReadCollection(acc.toString()); virtualHeader = loadSamHeader(); } catch (final Exception e) { throw new RuntimeException(e); } cachedReferences = new ReferenceCache(run, virtualHeader); recordRangeInfo = SRAIterator.getRecordsRangeInfo(run); index = new SRAIndex(virtualHeader, recordRangeInfo); }
public SRAFileReader(final SRAAccession acc) { this.acc = acc; if (!acc.isValid()) { throw new IllegalArgumentException("SRAFileReader: cannot resolve SRA accession '" + acc + "'\n" + "Possible causes are an invalid SRA accession or a connection problem."); } try { run = gov.nih.nlm.ncbi.ngs.NGS.openReadCollection(acc.toString()); virtualHeader = loadSamHeader(); } catch (final Exception e) { throw new RuntimeException(e); } cachedReferences = new ReferenceCache(run, virtualHeader); recordRangeInfo = SRAIterator.getRecordsRangeInfo(run); index = new SRAIndex(virtualHeader, recordRangeInfo); }
/** * Are the SRA native libraries loaded and initialized? Does the test accession have a valid name? */ @BeforeGroups(groups = {"sra"}) public final void checkIfCanResolve() { // Did SRA successfully load the native libraries and are fully initialized? if (!SRAAccession.isSupported()) { return; } // Is this is a valid SRA accession? canResolveNetworkAccession = SRAAccession.isValid(checkAccession); }
@BeforeGroups(groups = "sra") public final void checkIfCanResolve() { if (SRAAccession.checkIfInitialized() != null) { return; } canResolveNetworkAccession = SRAAccession.isValid(checkAccession); }
public ReaderInitializer call() { try { if (threadAllocation.getNumIOThreads() > 0) blockInputStream = new BlockInputStream(dispatcher,readerID,false); SamReaderFactory factory = SamReaderFactory.makeDefault() .validationStringency(validationStringency) .setOption(SamReaderFactory.Option.EAGERLY_DECODE, false); if (SRAAccession.isValid(readerID.getSamFile().getPath())) { reader = factory.open(SamInputResource.of(new SRAAccession(readerID.getSamFile().getPath()))); } else { reader = factory.referenceSequence(referenceFile) .setOption(SamReaderFactory.Option.INCLUDE_SOURCE_IN_RECORDS, true) .open(readerID.getSamFile()); } } catch ( RuntimeIOException e ) { throw new UserException.CouldNotReadInputFile(readerID.getSamFile(), e); } catch ( SAMFormatException e ) { throw new UserException.MalformedBAM(readerID.getSamFile(), e.getMessage()); } // Picard is throwing a RuntimeException here when BAMs are malformed with bad headers (and so look like SAM files). // Let's keep this separate from the SAMFormatException (which ultimately derives from RuntimeException) case, // just in case we want to change this behavior later. catch ( RuntimeException e ) { throw new UserException.MalformedBAM(readerID.getSamFile(), e.getMessage()); } return this; } }
if (!SRAAccession.isValid(readerID.getSamFile().getPath()) && !readerID.getSamFile().canRead() ) throw new UserException.CouldNotReadInputFile(readerID.getSamFile(),"file is not present or user does not have appropriate permissions. " + "Please check that the file is present and readable and try again."); ReferenceSequenceFile ref; if (SRAAccession.isValid(referenceFile.getPath())) { ref = new SRAIndexedSequenceFile(new SRAAccession(referenceFile.getPath())); } else {