package stream; import java.util.ArrayList; import dna.Data; import fileIO.ByteFile; import fileIO.ByteFile1; import fileIO.FileFormat; import shared.Shared; /** * @author Brian Bushnell * @date June 1, 2016 * */ public class HeaderInputStream extends ReadInputStream { public static void main(String[] args){ HeaderInputStream his=new HeaderInputStream(args[0], true); Read r=his.next(); System.out.println(r.toText(false)); his.close(); } public HeaderInputStream(String fname, boolean allowSubprocess_){ this(FileFormat.testInput(fname, FileFormat.FASTQ, null, allowSubprocess_, false)); } public HeaderInputStream(FileFormat ff){ if(verbose){System.err.println("FastqReadInputStream("+ff+")");} stdin=ff.stdio(); tf=new ByteFile1(ff); } @Override public void 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()); return list; } private synchronized void fillBuffer(){ assert(buffer==null || next>=buffer.size()); buffer=null; next=0; buffer=toReadList(tf, BUF_LEN, nextReadID); int bsize=(buffer==null ? 0 : buffer.size()); nextReadID+=bsize; if(bsize