Search in sources :

Example 1 with ParsingStreamConsumer

use of ubic.gemma.core.util.concurrent.ParsingStreamConsumer in project Gemma by PavlidisLab.

the class SimpleFastaCmd method getSequencesFromFastaCmdOutput.

private Collection<BioSequence> getSequencesFromFastaCmdOutput(Process pr) throws IOException {
    try (final InputStream is = new BufferedInputStream(pr.getInputStream());
        InputStream err = pr.getErrorStream()) {
        final FastaParser parser = new FastaParser();
        ParsingStreamConsumer<BioSequence> sg = new ParsingStreamConsumer<>(parser, is);
        GenericStreamConsumer gsc = new GenericStreamConsumer(err);
        sg.start();
        gsc.start();
        try {
            int exitVal = pr.waitFor();
            // Makes sure results are flushed.
            Thread.sleep(200);
            SimpleFastaCmd.log.debug(// often nonzero if some sequences are not found.
            "fastacmd exit value=" + exitVal);
            return parser.getResults();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ParsingStreamConsumer(ubic.gemma.core.util.concurrent.ParsingStreamConsumer) GenericStreamConsumer(ubic.gemma.core.util.concurrent.GenericStreamConsumer)

Aggregations

GenericStreamConsumer (ubic.gemma.core.util.concurrent.GenericStreamConsumer)1 ParsingStreamConsumer (ubic.gemma.core.util.concurrent.ParsingStreamConsumer)1 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)1