3 import std
.stdio
, std
.string
, std
.regex
, klib
;
5 void main(string
[] args
)
8 writeln("Usage: rdmd bc2rg.d <sample> <barcode-list.txt> <aln.sam>");
11 auto fp
= new ZFile(args
[2]);
14 char[] base
= ['A', 'C', 'G', 'T', 'N'];
16 while (fp
.readto(l
) >= 0) {
17 auto t
= std
.string
.split(cast(string
)l
);
18 if (t
.length
== 0) continue;
19 string r
= args
[1] ~ '-' ~ t
[0] ~ '-' ~ t
[1];
21 for (auto i
= 0; i
< t
[0].length
; ++i
) {
24 s
.length
= t
[0].length
;
25 s
[] = cast(char[])t
[0];
27 bc2rg
[cast(string
)s
] = r
;
32 fp
= new ZFile(args
[3]);
34 auto re
= regex(r
"^\S+#([ACGTN]+)");
35 while (fp
.readto(l
) >= 0) {
39 writefln("@RG\tID:%s\tSM:%s\tLB:%s", p
, args
[1], p
);
42 auto c
= match(cast(string
)l
, re
).captures
;
43 if (c
[1] in bc2rg
) writeln(cast(char[])l
, "\tRG:Z:", bc2rg
[c
[1]]);
44 else writeln(cast(char[])l
);
45 } else writeln(cast(char[])l
);