Skip to content

Commit

Permalink
updated mge report writer
Browse files Browse the repository at this point in the history
  • Loading branch information
jrober84 committed Aug 15, 2023
1 parent afd22d8 commit e807129
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions mob_suite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,70 +1299,6 @@ def blast_mge(contig_fasta, mge_fasta,tmp_dir, min_length, logging, min_rpp_iden

return results

def writeMGEresults(contig_membership,mge_results,outfile):
out_string = ["\t".join(MGE_INFO_HEADER)]
for contig_id in contig_membership['chromosome']:
if not contig_id in mge_results:
continue

for i in range(0, len(mge_results[contig_id])):
row = {}
for field in MGE_INFO_HEADER:
row[field] = ''
if field in mge_results[contig_id]:
row[field] = mge_results[contig_id][field]

id = mge_results[contig_id][i]['qseqid'].split('|')
row['mge_id'] = id[0]
row['mge_acs'] = id[1]
row['mge_type'] = id[2]
row['mge_subtype'] = id[3]
row['mge_length'] = mge_results[contig_id][i]['qlen']
row['mge_start'] = mge_results[contig_id][i]['qstart']
row['mge_end'] = mge_results[contig_id][i]['qend']
row['contig_start'] = mge_results[contig_id][i]['sstart']
row['contig_end'] = mge_results[contig_id][i]['send']

for field in contig_membership['chromosome'][contig_id]:
if field in row:
row[field] = contig_membership['chromosome'][contig_id][field]

out_string.append("\t".join([str(x) for x in list(row.values())]))

for mobcluster in contig_membership['plasmid']:
for contig_id in contig_membership['plasmid'][mobcluster]:
if not contig_id in mge_results:
continue

for i in range(0, len(mge_results[contig_id])):
row = {}
for field in MGE_INFO_HEADER:
row[field] = ''
if field in mge_results[contig_id][i]:
row[field] = mge_results[contig_id][i][field]
id = mge_results[contig_id][i]['qseqid'].split('|')
row['mge_id'] = id[0]
row['mge_acs'] = id[1]
row['mge_type'] = id[2]
row['mge_subtype'] = id[3]
row['mge_length'] = mge_results[contig_id][i]['qlen']
row['mge_start'] = mge_results[contig_id][i]['qstart']
row['mge_end'] = mge_results[contig_id][i]['qend']
row['contig_start'] = mge_results[contig_id][i]['sstart']
row['contig_end'] = mge_results[contig_id][i]['send']

for field in contig_membership['plasmid'][mobcluster][contig_id]:
if field in row:
row[field] = contig_membership['plasmid'][mobcluster][contig_id][field]

out_string.append("\t".join([str(x) for x in list(row.values())]))


fh = open(outfile,'w')
fh.write("\n".join(out_string))
fh.close()


def writeMGEresults(contig_membership,mge_results,outfile):
if len(mge_results) == 0:
return
Expand Down

0 comments on commit e807129

Please sign in to comment.