package stream; import java.util.ArrayList; import fileIO.ByteFile; import fileIO.FileFormat; import shared.Shared; public class ScarfReadInputStream extends ReadInputStream { public static void main(String[] args){ ScarfReadInputStream fris=new ScarfReadInputStream(args[0], true); Read r=fris.next(); System.out.println(r.toText(false)); } public ScarfReadInputStream(String fname, boolean allowSubprocess_){ this(FileFormat.testInput(fname, FileFormat.SCARF, null, allowSubprocess_, false)); } public ScarfReadInputStream(FileFormat ff){ if(verbose){System.err.println("ScarfReadInputStream("+ff.name()+")");} stdin=ff.stdio(); if(!ff.scarf()){ System.err.println("Warning: Did not find expected scarf file extension for filename "+ff.name()); } tf=ByteFile.makeByteFile(ff); interleaved=FASTQ.FORCE_INTERLEAVED;//((tf.is()==System.in || stdin) ? FASTQ.FORCE_INTERLEAVED : FASTQ.isInterleaved(tf.name)); // assert(false) : interleaved; } @Override public void start() { // if(cris!=null){cris.start();} } @Override public boolean hasMore() { if(buffer==null || next>=buffer.size()){ if(tf.isOpen()){ fillBuffer(); }else{ assert(generated>0) : "Was the file empty?"; } } return (buffer!=null && next nextList() { if(next!=0){throw new RuntimeException("'next' should not be used when doing blockwise access.");} if(buffer==null || next>=buffer.size()){fillBuffer();} ArrayList list=buffer; buffer=null; if(list!=null && list.size()==0){list=null;} consumed+=(list==null ? 0 : list.size()); // System.err.println(hashCode()+" produced "+r[0].numericID); return list; } private synchronized void fillBuffer(){ assert(buffer==null || next>=buffer.size()); buffer=null; next=0; buffer=FASTQ.toScarfReadList(tf, BUF_LEN, nextReadID, interleaved); int bsize=(buffer==null ? 0 : buffer.size()); nextReadID+=bsize; if(bsize