aboutsummaryrefslogtreecommitdiff
path: root/workflows/pangenome-generate/relabel-seqs.py
diff options
context:
space:
mode:
authorPeter Amstutz2020-04-20 14:57:25 -0400
committerPeter Amstutz2020-04-20 14:57:25 -0400
commit9ddcfeacb3191638f42b08af999889d867f0f81c (patch)
tree4cfe4c2b1df38bf6e5c79f5f8c0700407f76a472 /workflows/pangenome-generate/relabel-seqs.py
parentd29dfd593233541b85c1cefb239650279d57d59f (diff)
downloadbh20-seq-resource-9ddcfeacb3191638f42b08af999889d867f0f81c.tar.gz
bh20-seq-resource-9ddcfeacb3191638f42b08af999889d867f0f81c.tar.lz
bh20-seq-resource-9ddcfeacb3191638f42b08af999889d867f0f81c.zip
Better handling of duplicate sequences
Also save original fasta label in metadata
Diffstat (limited to 'workflows/pangenome-generate/relabel-seqs.py')
-rw-r--r--workflows/pangenome-generate/relabel-seqs.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/workflows/pangenome-generate/relabel-seqs.py b/workflows/pangenome-generate/relabel-seqs.py
index 32f2386..b558fe2 100644
--- a/workflows/pangenome-generate/relabel-seqs.py
+++ b/workflows/pangenome-generate/relabel-seqs.py
@@ -1,13 +1,15 @@
-import sys
-
reads = $(inputs.readsFA)
subjects = $(inputs.subjects)
+relabeled_fasta = open("relabeledSeqs.fasta", "wt")
+original_labels = open("originalLabels.ttl", "wt")
+
for i, r in enumerate(reads):
with open(r["path"], "rt") as fa:
- fa.readline()
- print(">"+subjects[i])
+ label = fa.readline()
+ original_labels.write("<%s> <http://biohackathon.org/bh20-seq-schema/original_fasta_label> \\"%s\\" .\\n" % (subjects[i], label[1:].strip().replace('"', '\\\\"')))
+ relabeled_fasta.write(">"+subjects[i]+"\\n")
data = fa.read(8096)
while data:
- sys.stdout.write(data)
+ relabeled_fasta.write(data)
data = fa.read(8096)