@@ -207,6 +207,24 @@ rule type_variants_p1:
207
207
--append-genotypes
208
208
"""
209
209
210
+ rule type_variants_p3 :
211
+ input :
212
+ fasta = rules .align_to_reference .output .fasta ,
213
+ variants = config ["p3_variants" ],
214
+ reference = config ["reference_fasta" ]
215
+ output :
216
+ variants = os .path .join (config ["tempdir" ],"variants_p3.csv" )
217
+ shell :
218
+ """
219
+ type_variants.py \
220
+ --fasta-in {input.fasta:q} \
221
+ --variants-config {input.variants:q} \
222
+ --reference {input.reference:q} \
223
+ --variants-out {output.variants:q} \
224
+ --append-genotypes
225
+ """
226
+
227
+
210
228
rule type_variants_b12142 :
211
229
input :
212
230
fasta = rules .align_to_reference .output .fasta ,
@@ -230,6 +248,7 @@ rule overwrite:
230
248
csv = os .path .join (config ["tempdir" ],"pangolearn_assignments.csv" ),
231
249
b117_variants = rules .type_variants_b117 .output .variants ,
232
250
b1351_variants = rules .type_variants_b1351 .output .variants ,
251
+ p3_variants = rules .type_variants_p3 .output .variants ,
233
252
p2_variants = rules .type_variants_p2 .output .variants ,
234
253
p1_variants = rules .type_variants_p1 .output .variants ,
235
254
b12142_variants = rules .type_variants_b12142 .output .variants
@@ -260,6 +279,12 @@ rule overwrite:
260
279
for row in reader :
261
280
if int (row ["alt_count" ]) > 4 and int (row ["ref_count" ])< 4 :
262
281
p2 [row ["query" ]] = row ["alt_count" ]
282
+ p3 = {}
283
+ with open (input .p3_variants , "r" ) as f :
284
+ reader = csv .DictReader (f )
285
+ for row in reader :
286
+ if int (row ["alt_count" ]) > 8 and int (row ["ref_count" ])< 4 :
287
+ p3 [row ["query" ]] = row ["alt_count" ]
263
288
b12142 = {}
264
289
with open (input .b12142_variants , "r" ) as f :
265
290
reader = csv .DictReader (f )
@@ -349,6 +374,23 @@ rule overwrite:
349
374
new_row ["probability" ] = "1.0"
350
375
new_row ["lineage" ] = "B.1.1.28"
351
376
377
+ writer .writerow (new_row )
378
+ elif row ["taxon" ] in p3 :
379
+ new_row = row
380
+ snps = p3 [row ["taxon" ]]
381
+ note = f"{ snps } /12 P.3 (B.1.1.28.3) SNPs"
382
+
383
+ new_row ["note" ] = note
384
+ new_row ["probability" ] = "1.0"
385
+ new_row ["lineage" ] = "P.3"
386
+
387
+ writer .writerow (new_row )
388
+ elif row ["lineage" ] == "P.3" and row ["taxon" ] not in p3 :
389
+ new_row = row
390
+
391
+ new_row ["probability" ] = "1.0"
392
+ new_row ["lineage" ] = "B.1.1.28"
393
+
352
394
writer .writerow (new_row )
353
395
elif row ["lineage" ] == "B.1.214" :
354
396
new_row = row
0 commit comments