Mercurial > repos > nick > duplex
annotate make-barcodes.awk @ 4:af383638de66 draft
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
| author | nick |
|---|---|
| date | Mon, 23 Nov 2015 18:44:23 -0500 |
| parents | |
| children |
| rev | line source |
|---|---|
|
4
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
1 # The awk code that transforms the one-line fastq record pair into the output that can be sorted |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
2 # by barcode. |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
3 # Input columns (the 4 FASTQ lines for both reads in a read pair): |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
4 # 1: read1 name |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
5 # 2: read2 name |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
6 # 3: read1 sequence |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
7 # 4: read2 sequence |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
8 # 5: read1 + line |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
9 # 6: read2 + line |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
10 # 7: read1 quality |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
11 # 8: read2 quality |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
12 # Output columns: |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
13 # 1: the barcode, put into a canonical form |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
14 # 2: the order of the barcode halves ("ab" or "ba") |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
15 # 3: read1 name |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
16 # 4: sequence of read 1, minus the 12bp barcode and 5bp invariant sequence |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
17 # 5: read1 quality scores, minus the same first 17bp |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
18 # 6: read2 name |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
19 # 7: sequence of read 2, minus the first 17bp |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
20 # 8: read2 quality scores, minus the first 17bp |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
21 # The canonical form of the barcode is composed of two concatenated tags, one from each read. |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
22 # By default, each tag is the first 12bp of the read. The tag from the first read is the "alpha" and |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
23 # the tag from the second is the "beta". The barcode is formed by concatenating them in an order |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
24 # determined by a string comparison of the two. The lesser tag is first (if they are equal, the |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
25 # beta is first, but then you have bigger problems). |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
26 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
27 BEGIN { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
28 FS = "\t" |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
29 OFS = "\t" |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
30 # The number of bases from the start of each read that form the two halves of the barcode. |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
31 # (this should be half the size of the full, canonical barcode). |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
32 if (TAG_LEN == "") { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
33 TAG_LEN = 12 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
34 } |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
35 # The number of bases in the read that are between the barcode and the start of the actual sample |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
36 # sequence (the restriction site in the Loeb 2014 protocol). |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
37 if (INVARIANT == "") { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
38 INVARIANT = 5 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
39 } |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
40 } |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
41 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
42 $3 && $4 { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
43 alpha = substr($3, 1, TAG_LEN) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
44 beta = substr($4, 1, TAG_LEN) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
45 if (alpha < beta) { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
46 barcode = alpha beta |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
47 order = "ab" |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
48 } else { |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
49 barcode = beta alpha |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
50 order = "ba" |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
51 } |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
52 name1 = $1 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
53 name2 = $2 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
54 seq1 = substr($3, TAG_LEN + INVARIANT + 1) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
55 seq2 = substr($4, TAG_LEN + INVARIANT + 1) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
56 qual1 = substr($7, TAG_LEN + INVARIANT + 1) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
57 qual2 = substr($8, TAG_LEN + INVARIANT + 1) |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
58 print barcode, order, name1, seq1, qual1, name2, seq2, qual2 |
|
af383638de66
planemo upload commit 022984f323d3da44f70b3bf79c684cfd8dda3f61-dirty
nick
parents:
diff
changeset
|
59 } |
