public Iterator<BinaryInteraction> iterate(Reader reader) throws IOException { final BufferedReader bufferedReader = new BufferedReader(reader); return new PsimiTabIterator(bufferedReader); }
public BinaryInteraction next() { if (nextLine == null && !hasNext()) { throw new NoSuchElementException(); } BinaryInteraction interaction = nextLine; interactionsProcessedCount++; lineConsummed = true; nextLine = null; return interaction; }
public boolean hasNext() { try { if (interactionStreamReader != null && lineConsummed) { String line = interactionStreamReader.readLine(); nextLine = line != null ? mReader.readLine(line) : null; if (nextLine == null) { closeStreamReader(); interactionStreamReader = null; } else { lineIndex++; lineConsummed = false; } } } catch (Exception e) { closeStreamReader(); throw new RuntimeException("Error while reading the file.", e); } return (nextLine != null); }
public PsimiTabIterator(Reader psiMiTabInteractionsReader) { boolean isHeader = true; if (psiMiTabInteractionsReader == null) { throw new IllegalArgumentException("You must give a non null input stream."); } if (psiMiTabInteractionsReader instanceof BufferedReader) { this.interactionStreamReader = (BufferedReader) psiMiTabInteractionsReader; } else { this.interactionStreamReader = new BufferedReader(psiMiTabInteractionsReader); } this.mReader = new PsimiTabReader(); try { do { String firstLine = interactionStreamReader.readLine(); if(firstLine == null){ nextLine = null; isHeader = false; } else if (!firstLine.isEmpty() && !firstLine.startsWith("#")) { //This line is not a comment, we read nextLine = mReader.readLine(firstLine); lineIndex++; isHeader = false; } } while (isHeader); } catch (Exception e) { closeStreamReader(); throw new RuntimeException("Error while reading the header line.", e); } }
public Iterator<BinaryInteraction> iterate(File file) throws IOException { final FileReader reader = new FileReader(file); final BufferedReader bufferedReader = new BufferedReader(reader); return new PsimiTabIterator(bufferedReader); }
public Iterator<BinaryInteraction> iterate(InputStream is) throws IOException { final InputStreamReader reader = new InputStreamReader(is); final BufferedReader bufferedReader = new BufferedReader(reader); return new PsimiTabIterator(bufferedReader); }
public Iterator<BinaryInteraction> iterate(String s) throws IOException { final ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes()); final InputStreamReader reader = new InputStreamReader(is); final BufferedReader bufferedReader = new BufferedReader(reader); return new PsimiTabIterator(bufferedReader); }