private void parseHeader() { AsciiLineReader reader = null; // The DataConsumer interface takes an array of data per position, however wig // files contain a single data point. Create an "array" once that can // be resused try { reader = ParsingUtils.openAsciiReader(resourceLocator); while ((nextLine = reader.readLine()) != null && (nextLine.trim().length() > 0)) { // Skip comment lines if (nextLine.startsWith("#") || nextLine.startsWith("data") || nextLine.startsWith( "browser") || nextLine.trim().length() == 0) { continue; } if (nextLine.startsWith("track")) { trackLine = nextLine; } else { return; } } } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { reader.close(); } } }
public static boolean parsableMAGE_TAB(ResourceLocator file) throws IOException { AsciiLineReader reader = null; try { reader = ParsingUtils.openAsciiReader(file); String nextLine = null; //skip first row reader.readLine(); //check second row for MAGE_TAB identifiers if ((nextLine = reader.readLine()) != null && (nextLine.contains("Reporter REF") || nextLine.contains("Composite Element REF") || nextLine.contains("Term Source REF") || nextLine.contains("CompositeElement REF") || nextLine.contains("TermSource REF") || nextLine.contains("Coordinates REF"))) { return true; } } finally { if (reader != null) { reader.close(); } } return false; }
} finally { if (reader != null) { reader.close();
public static boolean parsableMAGE_TAB(ResourceLocator file) throws IOException { AsciiLineReader reader = null; try { reader = ParsingUtils.openAsciiReader(file); String nextLine = null; //skip first row reader.readLine(); //check second row for MAGE_TAB identifiers if ((nextLine = reader.readLine()) != null && (nextLine.contains("Reporter REF") || nextLine.contains("Composite Element REF") || nextLine.contains("Term Source REF") || nextLine.contains("CompositeElement REF") || nextLine.contains("TermSource REF") || nextLine.contains("Coordinates REF"))) { int count = 0; // check if this mage_tab data matrix can be parsed by this class while ((nextLine = reader.readLine()) != null && count < 5) { nextLine = nextLine.trim(); if (nextLine.startsWith("SNP_A") || nextLine.startsWith("CN_")) { return true; } count++; } return false; } } finally { if (reader != null) { reader.close(); } } return false; }
e.printStackTrace(); } finally { reader.close();
MessageUtils.showMessage("Error loading snps file: " + snpFile + " (" + e.toString() + ")"); } finally { reader.close();
e.printStackTrace(); } finally { reader.close();
/** A VCFHeader is read from the input Path. */ public VCFRecordWriter( Path output, Path input, boolean writeHeader, TaskAttemptContext ctx) throws IOException { final AsciiLineReader r = new AsciiLineReader( input.getFileSystem(ctx.getConfiguration()).open(input)); final FeatureCodecHeader h = codec.readHeader(new AsciiLineReaderIterator(r)); if (h == null || !(h.getHeaderValue() instanceof VCFHeader)) throw new IOException("No VCF header found in "+ input); r.close(); init(output, (VCFHeader) h.getHeaderValue(), writeHeader, ctx); } public VCFRecordWriter(
/** A VCFHeader is read from the input Path. */ public VCFRecordWriter( Path output, Path input, boolean writeHeader, TaskAttemptContext ctx) throws IOException { final AsciiLineReader r = new AsciiLineReader( input.getFileSystem(ctx.getConfiguration()).open(input)); final FeatureCodecHeader h = codec.readHeader(new AsciiLineReaderIterator(r)); if (h == null || !(h.getHeaderValue() instanceof VCFHeader)) throw new IOException("No VCF header found in "+ input); r.close(); init(output, (VCFHeader) h.getHeaderValue(), writeHeader, ctx); } public VCFRecordWriter(
/** A VCFHeader is read from the input Path. */ public VCFRecordWriter( Path output, Path input, boolean writeHeader, TaskAttemptContext ctx) throws IOException { final AsciiLineReader r = new AsciiLineReader( input.getFileSystem(ctx.getConfiguration()).open(input)); final FeatureCodecHeader h = codec.readHeader(new AsciiLineReaderIterator(r)); if (h == null || !(h.getHeaderValue() instanceof VCFHeader)) throw new IOException("No VCF header found in "+ input); r.close(); init(output, (VCFHeader) h.getHeaderValue(), writeHeader, ctx); } public VCFRecordWriter(
} finally { if (bufReader != null) { bufReader.close();
throw new DataLoadException("IO Exception: " + e.toString(), locator.getPath()); } finally { reader.close();
reader.close();
/** * Returns either 1 or 2, representing the number of * bytes used to end a line. Reads only from first line of a file * * @param filePath * @return * @throws IOException */ public static int getBytesAtEnd(String filePath) throws IOException { InputStream is = new FileInputStream(filePath); AsciiLineReader reader = new AsciiLineReader(is); String line = reader.readLine(); int bytesThisLine = (int) reader.getPosition(); reader.close(); return bytesThisLine - line.length(); }
} finally { if (reader != null) { reader.close();
if(reader != null) reader.close();
if(reader != null) reader.close();
/** * Load attributes from an ascii file in "Sample Info" format. */ public void loadSampleInfo(ResourceLocator locator) { AsciiLineReader reader = null; try { reader = ParsingUtils.openAsciiReader(locator); loadSampleTable(reader, locator.getPath()); loadedResources.add(locator); if (!Globals.isHeadless()) { IGV.getInstance().resetOverlayTracks(); IGV.getInstance().doRefresh(); } } catch (IOException ex) { log.error("Error loading attribute file", ex); throw new DataLoadException("Error reading attribute file", locator.getPath()); } finally { if (reader != null) { reader.close(); } firePropertyChange(this, ATTRIBUTES_LOADED_PROPERTY, null, null); } }
} finally { try { reader.close(); } catch (Exception e) {
reader.close();