| 1 | package stream; |
| 2 | |
| 3 | import structures.ListNum; |
| 4 | |
| 5 | public interface ConcurrentReadStreamInterface extends Runnable{ |
| 6 | |
| 7 | /** Start this in a new thread. */ |
| 8 | public void start(); |
| 9 | |
| 10 | /** Fetch the next list of reads. Returns an empty list when end of input is reached. */ |
| 11 | public ListNum<Read> nextList(); |
| 12 | |
| 13 | /** Re-calls returnList(returnList(ln.id, ln.list.isEmpty()) */ |
| 14 | public void returnList(ListNum<Read> ln); |
| 15 | |
| 16 | /** When the nextList() caller is done processing a list, it MUST be returned using this method. |
| 17 | * The 'poison' flag should be set to false normally. When a consumer thread receives an empty list from nextList(), |
| 18 | * it should be returned with the poison flag set to true, then the consumer should terminate. |
| 19 | * This will return a list to the 'full' queue, allowing another thread to pull the empty list and terminate. */ |
| 20 | public void returnList(long listNumber, boolean poison); |
| 21 | |
| 22 | /** This must be called (indirectly, via Thread.start()) before reads will be generated. */ |
| 23 | @Override |
| 24 | public void run(); |
| 25 | |
| 26 | /** Indicate to producer threads that no more reads are desired, and interrupts them. */ |
| 27 | public void shutdown(); |
| 28 | |
| 29 | /** Reset state to allow production of reads from the beginning of the input files. |
| 30 | * Does not work with stdin (may cause strange behavior). */ |
| 31 | public void restart(); |
| 32 | |
| 33 | /** Calls shutdown, then shuts down all threads and closes all associated files. */ |
| 34 | public void close(); |
| 35 | |
| 36 | /** Returns true for paired-end stream, false for single-end stream. */ |
| 37 | public boolean paired(); |
| 38 | |
| 39 | /** Name of the file or resource underlying this stream */ |
| 40 | public String fname(); |
| 41 | |
| 42 | /** Returns the underlying read object producer(s), such as ReadInputStreams. Optional method for things such as error messages. */ |
| 43 | public Object[] producers(); |
| 44 | |
| 45 | /** Return true if this stream or its producers have detected an error. */ |
| 46 | public boolean errorState(); |
| 47 | |
| 48 | /** |
| 49 | * Set the read sampling rate. Optional method. |
| 50 | * @param rate Fraction of reads to use, 0-1. |
| 51 | * @param seed Random number generator seed when positive. If negative, a random seed will be used. |
| 52 | */ |
| 53 | public void setSampleRate(float rate, long seed); |
| 54 | |
| 55 | /** |
| 56 | * @return Number of bases read by this stream. |
| 57 | */ |
| 58 | public long basesIn(); |
| 59 | |
| 60 | /** |
| 61 | * @return Number of reads read by this stream. |
| 62 | */ |
| 63 | public long readsIn(); |
| 64 | |
| 65 | /** |
| 66 | * @return Value of verbose field. |
| 67 | */ |
| 68 | public boolean verbose(); |
| 69 | |
| 70 | // public String classname(); //e.g. getClass().getName() |
| 71 | |
| 72 | } |