Genewise { public static Iterable<GenewiseExon> genewiseExons(final File aminoAcidHmm2File, final File genomicDnaFastaFile) throws IOException { checkNotNull(aminoAcidHmm2File); checkNotNull(genomicDnaFastaFile); File genewiseResult = File.createTempFile("genewise", ".txt"); ProcessBuilder genewise = new ProcessBuilder("genewise", "-hmmer", "-tfor", "-genes", "-nosplice_gtag", aminoAcidHmm2File.getPath(), genomicDnaFastaFile.getPath()); genewise.redirectErrorStream(true); genewise.redirectOutput(ProcessBuilder.Redirect.to(genewiseResult)); Process genewiseProcess = genewise.start(); try { genewiseProcess.waitFor(); } catch (InterruptedException e) { } int lineNumber = 0; BufferedReader reader = null; List<GenewiseExon> exons = Lists.newLinkedList(); try { reader = new BufferedReader(new FileReader(genewiseResult)); while (reader.ready()) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(" Exon")) { List<String> tokens = SPLITTER.splitToList(line); if (tokens.size() < 5) { throw new IOException("invalid genewise genes format at line number " + lineNumber + ", line " + line); } try { long start = Long.parseLong(tokens.get(1)); long end = Long.parseLong(tokens.get(2)); if (start > end) { throw new IOException("invalid genewise exon at line number " + lineNumber + ", start > end"); } int phase = Integer.parseInt(tokens.get(4)); exons.add(new GenewiseExon(start, end, phase)); } catch (NumberFormatException e) { throw new IOException("invalid genewise exon at line number " + lineNumber + ", caught " + e.getMessage()); } } lineNumber++; } } finally { try { reader.close(); } catch (Exception e) { } try { genewiseResult.delete(); } catch (Exception e) { } } return ImmutableList.copyOf(exons); } private  Genewise(); static Iterable<GenewiseExon> genewiseExons(final File aminoAcidHmm2File, final File genomicDnaFastaFile);  }
@Test(expected=NullPointerException.class) public void testGenewiseExonsNullAminoAcidHmm2File() throws Exception { genewiseExons(null, genomicDnaFastaFile); }
@Test(expected=NullPointerException.class) public void testGenewiseExonsNullGenomicDnaFastaFile() throws Exception { genewiseExons(aminoAcidHmm2File, null); }