| 1 |
package jgi; |
| 2 |
|
| 3 |
import java.io.File; |
| 4 |
import java.util.ArrayList; |
| 5 |
|
| 6 |
import fileIO.ByteStreamWriter; |
| 7 |
import fileIO.FileFormat; |
| 8 |
import shared.Parser; |
| 9 |
import shared.PreParser; |
| 10 |
import shared.Shared; |
| 11 |
import shared.Timer; |
| 12 |
import shared.Tools; |
| 13 |
import structures.ByteBuilder; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class AssemblyStats3 { |
| 23 |
|
| 24 |
public static void main(String[] args){ |
| 25 |
|
| 26 |
Timer t=new Timer(); |
| 27 |
|
| 28 |
|
| 29 |
AssemblyStats3 x=new AssemblyStats3(args); |
| 30 |
|
| 31 |
|
| 32 |
x.process(t); |
| 33 |
|
| 34 |
|
| 35 |
Shared.closeStream(x.outstream); |
| 36 |
} |
| 37 |
|
| 38 |
public AssemblyStats3(String[] args){ |
| 39 |
|
| 40 |
{ |
| 41 |
PreParser pp=new PreParser(args, getClass(), false); |
| 42 |
args=pp.args; |
| 43 |
outstream=pp.outstream; |
| 44 |
} |
| 45 |
|
| 46 |
Parser parser=new Parser(); |
| 47 |
parser.out1=out1; |
| 48 |
for(int i=0; i<args.length; i++){ |
| 49 |
String arg=args[i]; |
| 50 |
String[] split=arg.split("="); |
| 51 |
String a=split[0].toLowerCase(); |
| 52 |
String b=split.length>1 ? split[1] : null; |
| 53 |
if(b!=null && b.equalsIgnoreCase("null")){b=null;} |
| 54 |
|
| 55 |
if(a.equals("parse_flag_goes_here")){ |
| 56 |
|
| 57 |
}else if(a.equals("in")){ |
| 58 |
in.clear(); |
| 59 |
String[] b2=(b==null) ? null : (new File(b).exists() ? new String[] {b} : b.split(",")); |
| 60 |
for(String b3 : b2){in.add(b3);} |
| 61 |
}else if(b==null && new File(arg).exists()){ |
| 62 |
in.add(arg); |
| 63 |
}else if(parser.parse(arg, a, b)){ |
| 64 |
|
| 65 |
}else{ |
| 66 |
assert(false) : "Unknown parameter "+args[i]; |
| 67 |
outstream.println("Unknown parameter "+args[i]); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
{ |
| 72 |
Parser.processQuality(); |
| 73 |
|
| 74 |
maxReads=parser.maxReads; |
| 75 |
out1=parser.out1; |
| 76 |
} |
| 77 |
|
| 78 |
ffout1=FileFormat.testOutput(out1, FileFormat.TXT, null, true, true, false, false); |
| 79 |
} |
| 80 |
|
| 81 |
void process(Timer t){ |
| 82 |
|
| 83 |
final ByteStreamWriter bsw=ByteStreamWriter.makeBSW(ffout1); |
| 84 |
if(bsw!=null) {bsw.println(makeHeader());} |
| 85 |
|
| 86 |
for(String s : in) { |
| 87 |
processInner(s, bsw); |
| 88 |
} |
| 89 |
|
| 90 |
if(bsw!=null) {bsw.poisonAndWait();} |
| 91 |
if(verbose){outstream.println("Finished.");} |
| 92 |
|
| 93 |
t.stop(); |
| 94 |
Tools.timeLinesBytesProcessed(t, linesProcessed, bytesProcessed, 12); |
| 95 |
} |
| 96 |
|
| 97 |
public static String makeHeader() { |
| 98 |
ByteBuilder bb=new ByteBuilder(); |
| 99 |
bb.append("fname"); |
| 100 |
bb.tab().append("size"); |
| 101 |
bb.tab().append("contigs"); |
| 102 |
bb.tab().append("gc"); |
| 103 |
bb.tab().append("maxContig"); |
| 104 |
bb.tab().append("5kplus"); |
| 105 |
bb.tab().append("10kplus"); |
| 106 |
bb.tab().append("25kplus"); |
| 107 |
bb.tab().append("50kplus"); |
| 108 |
return bb.toString(); |
| 109 |
} |
| 110 |
|
| 111 |
void processInner(String fname, ByteStreamWriter bsw) { |
| 112 |
Assembly a=new Assembly(fname); |
| 113 |
if(bsw==null) {return;} |
| 114 |
int max=a.contigs.size>0 ? a.contigs.get(0) : 0; |
| 115 |
bsw.print(fname).tab().print(a.length).tab().print(a.contigs.size); |
| 116 |
bsw.tab().print(a.gc(), 3).tab().print(max); |
| 117 |
bsw.tab().print(a.lengthAtLeast(5000)); |
| 118 |
bsw.tab().print(a.lengthAtLeast(10000)); |
| 119 |
bsw.tab().print(a.lengthAtLeast(25000)); |
| 120 |
bsw.tab().print(a.lengthAtLeast(50000)); |
| 121 |
bsw.nl(); |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
private ArrayList<String> in=new ArrayList<String>(); |
| 129 |
private String out1="stdout.txt"; |
| 130 |
|
| 131 |
private final FileFormat ffout1; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
private long maxReads=-1; |
| 136 |
private long linesProcessed=0, bytesProcessed=0; |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
private java.io.PrintStream outstream=System.err; |
| 141 |
public static boolean verbose=false; |
| 142 |
|
| 143 |
} |