Skip to content
Snippets Groups Projects
Commit 1988a382 authored by christine.tranchant_ird.fr's avatar christine.tranchant_ird.fr
Browse files

add afunction format

parent f5ae058c
No related branches found
No related tags found
1 merge request!1Draft: Resolve "Vecscreen"
from Bio import SeqIO
import os
import sys
def format_60(txt):
output = ''
cpt = 0
for c in txt:
if cpt < 60:
output += c
cpt += 1
else:
output += '\n' + c
cpt = 1
return (output)
nb_seq, nb_seq_no_hits, nb_seq_suspicious = 0, 0, 0
if len(sys.argv) >= 3:
......@@ -16,7 +29,7 @@ with open(os.path.join(output_fasta), "w") as o:
with open(tmp_file, "w") as tmp:
tmp.write('>' + str(seq.description) + '\n')
tmp.write(gs.format_60(str(seq.seq)) + '\n')
tmp.write(format_60(str(seq.seq)) + '\n')
cmd = f'vecscreen -db {input_univec} -query {tmp_file} -outfmt 1 -text_output'
print(f"\t\t\ {seq.description} : vecscreen cmd : {cmd}")
......@@ -30,7 +43,7 @@ with open(os.path.join(output_fasta), "w") as o:
if 'No hits found' in process.stdout:
o.write('>' + str(seq.description) + '\n')
o.write(gs.format_60(str(seq.seq)) + '\n')
o.write(format_60(str(seq.seq)) + '\n')
nb_seq += 1
nb_seq_no_hits += 1
else:
......@@ -54,7 +67,7 @@ with open(os.path.join(output_fasta), "w") as o:
header_fields = str(seq.description).split()
o.write('>' + header_fields[0] + " " + str(new_length) + " " + " ".join(
header_fields[2:]) + '\n')
o.write(gs.format_60(str(seq.seq[min_seq:max_seq])) + '\n')
o.write(format_60(str(seq.seq[min_seq:max_seq])) + '\n')
nb_seq += 1
elif max_bounds == max_seq:
max_seq = min_bounds
......@@ -63,7 +76,7 @@ with open(os.path.join(output_fasta), "w") as o:
header_fields = str(seq.description).split()
o.write('>' + header_fields[0] + " " + str(new_length) + " " + " ".join(
header_fields[2:]) + '\n')
o.write(gs.format_60(str(seq.seq[min_seq:max_seq])) + '\n')
o.write(format_60(str(seq.seq[min_seq:max_seq])) + '\n')
nb_seq += 1
else:
print("Warning (seq : " + str(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment