Skip to content

Commit

Permalink
added 'sample_id' to headers for 'final_plasmid.tsv' and 'custom_plas…
Browse files Browse the repository at this point in the history
…mid.txt' output files (#50)
  • Loading branch information
DiDigsDNA authored and dfornika committed May 16, 2019
1 parent 8ed390d commit 6277800
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpo_pipeline/plasmids/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def main(args):

with open(plasmid_output_final, 'w+') as f:
fieldnames = [
'sample_id',
'accession',
'circularity',
'plasmid_length',
Expand All @@ -369,14 +370,17 @@ def main(args):
'allele',
'incompatibility_group'
]

writer = csv.DictWriter(f, fieldnames=fieldnames, delimiter='\t', extrasaction='ignore')
writer.writeheader()
if custom_best_candidate:
f.write(args.sample_id + '\t')
# Truncate floats to 4 digits
writer.writerow({k:round(v,4) if isinstance(v,float) else v for k,v in custom_best_candidate.items()})

with open(plasmid_output_summary, 'w+') as f:
fieldnames = [
'sample_id',
'accession',
'circularity',
'plasmid_length',
Expand All @@ -387,6 +391,7 @@ def main(args):
'incompatibility_group'
]
writer = csv.DictWriter(f, fieldnames=fieldnames, delimiter='\t', extrasaction='ignore')
writer.writeheader()
for candidate in custom_candidates:
f.write(args.sample_id + '\t')
# Truncate floats to 4 digits
Expand Down

0 comments on commit 6277800

Please sign in to comment.