本文整理汇总了Java中htsjdk.samtools.util.IOUtil.assertFileIsReadable方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtil.assertFileIsReadable方法的具体用法?Java IOUtil.assertFileIsReadable怎么用?Java IOUtil.assertFileIsReadable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.util.IOUtil
的用法示例。
在下文中一共展示了IOUtil.assertFileIsReadable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unrollFileCollection
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
/** return 'inputs' as set, if a filename ends with '*.list'
* is is considered as a file:one file per line
* @param inputs files
* @return set of files
*/
public static LinkedHashSet<File> unrollFileCollection(java.util.Collection<File> inputs)
{
LinkedHashSet<File> vcfFiles= new LinkedHashSet<>(inputs.size()+1);
for(File file : inputs)
{
if(file.getName().endsWith(".list"))
{
IOUtil.assertFileIsReadable(file);
for (final String s : IOUtil.readLines(file))
{
if (s.endsWith("#")) continue;
if (s.trim().isEmpty()) continue;
vcfFiles.add(new File(s));
}
}
else
{
vcfFiles.add(file);
}
}
return vcfFiles;
}
示例2: BamToBfqWriter
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
/**
* Constructor
*
* @param bamFile the BAM file to read from
* @param outputPrefix the directory and file prefix for the binary fastq files
* @param total the total number of records that should be written, drawn evenly
* from throughout the file (null for all).
* @param chunk the maximum number of records that should be written to any one file
* @param pairedReads whether these reads are from a paired-end run
* @param namePrefix The string to be stripped off the read name
* before writing to the bfq file. May be null, in which case
* the name will not be trimmed.
* @param includeNonPfReads whether to include non pf-reads
* @param clipAdapters whether to replace adapters as marked with XT:i clipping position attribute
*/
public BamToBfqWriter(final File bamFile, final String outputPrefix, final Integer total,
final Integer chunk, final boolean pairedReads, String namePrefix,
boolean includeNonPfReads, boolean clipAdapters, Integer basesToWrite) {
IOUtil.assertFileIsReadable(bamFile);
this.bamFile = bamFile;
this.outputPrefix = outputPrefix;
this.pairedReads = pairedReads;
if (total != null) {
final double writeable = (double)countWritableRecords();
this.increment = (int)Math.floor(writeable/total.doubleValue());
if (this.increment == 0) {
this.increment = 1;
}
}
if (chunk != null) {
this.chunk = chunk;
}
this.namePrefix = namePrefix;
this.nameTrim = namePrefix != null ? namePrefix.length() : 0;
this.includeNonPfReads = includeNonPfReads;
this.clipAdapters = clipAdapters;
this.basesToWrite = basesToWrite;
}
示例3: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
if(OUTPUT != null) IOUtil.assertFileIsWritable(OUTPUT);
final MetricsFile<CrosscheckMetric, ?> metricsFile = getMetricsFile();
try {
metricsFile.read(new FileReader(INPUT));
} catch (FileNotFoundException e) {
e.printStackTrace();
return 1;
}
clusterMetrics(metricsFile.getMetrics()).write(OUTPUT);
return 0;
}
示例4: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsWritable(OUTPUT);
IntervalList intervals = IntervalList.fromFile(INPUT);
if (SORT) intervals = intervals.sorted();
try {
final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT);
for (final Interval i : intervals) {
final String strand = i.isNegativeStrand() ? "-" : "+";
final List<?> fields = CollectionUtil.makeList(i.getContig(), i.getStart()-1, i.getEnd(), i.getName(), SCORE, strand);
out.append(fields.stream().map(String::valueOf).collect(Collectors.joining("\t")));
out.newLine();
}
out.close();
}
catch (IOException ioe) {
throw new RuntimeIOException(ioe);
}
return 0;
}
示例5: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsWritable(OUTPUT);
if (INPUT.getAbsolutePath().endsWith(".sam")) {
throw new PicardException("SAM files are not supported");
}
final SAMFileHeader samFileHeader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).getFileHeader(INPUT);
for (final String comment : COMMENT) {
if (comment.contains("\n")) {
throw new PicardException("Comments can not contain a new line");
}
samFileHeader.addComment(comment);
}
BamFileIoUtils.reheaderBamFile(samFileHeader, INPUT, OUTPUT, CREATE_MD5_FILE, CREATE_INDEX);
return 0;
}
示例6: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
@Override protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
try {
final FileTermination term = BlockCompressedInputStream.checkTermination(INPUT);
System.err.println(term.name());
if (term == FileTermination.DEFECTIVE) {
return 100;
}
else {
return 0;
}
}
catch (IOException ioe) {
throw new PicardException("Exception reading terminator block of file: " + INPUT.getAbsolutePath());
}
}
示例7: createPUPairsMap
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
private Map<String, Map<String, MatePair>> createPUPairsMap(final File samFile) throws IOException {
IOUtil.assertFileIsReadable(samFile);
final SamReader reader = SamReaderFactory.makeDefault().open(samFile);
final Map<String, Map<String, MatePair>> map = new LinkedHashMap<String, Map<String,MatePair>>();
Map<String,MatePair> curFileMap;
for (final SAMRecord record : reader ) {
final String platformUnit = record.getReadGroup().getPlatformUnit();
curFileMap = map.get(platformUnit);
if(curFileMap == null)
{
curFileMap = new LinkedHashMap<String, MatePair>();
map.put(platformUnit, curFileMap);
}
MatePair mpair = curFileMap.get(record.getReadName());
if (mpair == null) {
mpair = new MatePair();
curFileMap.put(record.getReadName(), mpair);
}
mpair.add(record);
}
reader.close();
return map;
}
示例8: openFileForReading
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public static InputStream openFileForReading(File file) throws IOException
{
IOUtil.assertFileIsReadable(file);
InputStream in= new FileInputStream(file);
if(file.getName().endsWith(".gz") || file.getName().endsWith(".bgz"))
{
in=tryBGZIP(in);
}
return in;
}
示例9: unrollFiles
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
/** return 'inputs' as set, if a filename ends with '*.list'
* is is considered as a file:one file per line
* @param inputs files
* @return set of files
*/
public static LinkedHashSet<String> unrollFiles(java.util.Collection<String> inputs)
{
LinkedHashSet<String> vcfFiles= new LinkedHashSet<>(inputs.size()+1);
for(String file : inputs)
{
if(file.isEmpty())
{
//ignore
}
else if(IOUtil.isUrl(file))
{
vcfFiles.add(file);
}
else if(file.endsWith(".list"))
{
File f = new File(file);
IOUtil.assertFileIsReadable(f);
for (final String s : IOUtil.readLines(f))
{
if (s.endsWith("#")) continue;
if (s.trim().isEmpty()) continue;
vcfFiles.add(s);
}
}
else
{
vcfFiles.add(file);
}
}
return vcfFiles;
}
示例10: checkFactoryVars
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
private static void checkFactoryVars(final int headerSize, final File binaryFile) {
IOUtil.assertFileIsReadable(binaryFile);
if(headerSize < 0) {
throw new PicardException("Header size cannot be negative. HeaderSize(" + headerSize + ") for file " + binaryFile.getAbsolutePath());
}
if(headerSize > binaryFile.length()) {
throw new PicardException("Header size(" + headerSize + ") is greater than file size(" + binaryFile.length() + ") for file " + binaryFile.getAbsolutePath());
}
}
示例11: assertIoFiles
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
private void assertIoFiles(final File summaryFile, final File detailsFile, final File plotsFile) {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE);
IOUtil.assertFileIsWritable(summaryFile);
IOUtil.assertFileIsWritable(detailsFile);
IOUtil.assertFileIsWritable(plotsFile);
}
示例12: getReadCounts
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
private int getReadCounts(final Path tempDirectory, final String baseName, final String fileName) {
final File path = tempDirectory.resolve(fileName).toFile();
IOUtil.assertFileIsReadable(path);
final SamReader in = SamReaderFactory.makeDefault().referenceSequence(new File(getTestDataDir(), getReferenceSequenceName(baseName))).open(path);
int count = 0;
for (@SuppressWarnings("unused") final SAMRecord rec : in) {
count++;
}
CloserUtil.close(in);
return count;
}
示例13: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
/**
* Main method for the program. Checks that input file is present and
* readable, then iterates through the index printing meta data to stdout.
*/
protected int doWork() {
if (INPUT.getName().endsWith(BAMIndex.BAMIndexSuffix))
log.warn("INPUT should be the BAM file name, not its index file");
IOUtil.assertFileIsReadable(INPUT);
BAMIndexMetaData.printIndexStats(INPUT);
return 0;
}
示例14: doWork
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
/**
* Do the work after command line has been parsed.
* RuntimeException may be thrown by this method, and are reported appropriately.
*
* @return program exit status.
*/
@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsWritable(OUTPUT);
final SamReaderFactory factory = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE);
if (VALIDATION_STRINGENCY == ValidationStringency.STRICT) {
factory.validationStringency(ValidationStringency.LENIENT);
}
final SamReader reader = factory.open(INPUT);
final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(reader.getFileHeader(), true, OUTPUT);
final CloseableIterator<SAMRecord> it = reader.iterator();
final ProgressLogger progress = new ProgressLogger(Log.getInstance(CleanSam.class));
// If the read (or its mate) maps off the end of the alignment, clip it
while (it.hasNext()) {
final SAMRecord rec = it.next();
// If the read (or its mate) maps off the end of the alignment, clip it
AbstractAlignmentMerger.createNewCigarsIfMapsOffEndOfReference(rec);
// check the read's mapping quality
if (rec.getReadUnmappedFlag() && 0 != rec.getMappingQuality()) {
rec.setMappingQuality(0);
}
writer.addAlignment(rec);
progress.record(rec);
}
writer.close();
it.close();
CloserUtil.close(reader);
return 0;
}
示例15: customCommandLineValidation
import htsjdk.samtools.util.IOUtil; //导入方法依赖的package包/类
protected String[] customCommandLineValidation() {
IOUtil.assertFileIsReadable(INPUT);
boolean isBamOrSamFile = isBamOrSamFile(INPUT);
if (!isBamOrSamFile && IGNORE_READ_GROUPS) {
return new String[]{"The parameter IGNORE_READ_GROUPS can only be used with BAM/SAM inputs."};
}
if (isBamOrSamFile && OBSERVED_SAMPLE_ALIAS != null) {
return new String[]{"The parameter OBSERVED_SAMPLE_ALIAS can only be used with a VCF input."};
}
return super.customCommandLineValidation();
}