Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phandango fix #47

Merged
merged 3 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions ariba/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,22 @@ def _write_phandango_csv(cls, rows, outfile):
# columns the same, and then all variant columns the same
header_line = ['name']
var_regex = re.compile('^.*;var\.[np.]\.\S+$')
var_columns = []

for heading in rows[0][1:]:
if var_regex.search(heading) is None:
header_line.append(heading + ':z1')
else:
header_line.append(heading + ':z2')
for i in range(1, len(rows[0]), 1):
heading = rows[0][i]
if var_regex.search(heading) is not None:
var_columns.append(i)

header_line.append(heading + ':o1')

f = pyfastaq.utils.open_file_write(outfile)
print(*header_line, sep=',', file=f)
for row in rows[1:]:
print(*row, sep=',', file=f)
to_print = list(row)
for i in var_columns:
to_print[i] *= 3
print(*to_print, sep=',', file=f)
pyfastaq.utils.close(f)


Expand Down
2 changes: 1 addition & 1 deletion ariba/tasks/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def run():
usage = 'ariba summary [options] <outfile> [report1.tsv report2.tsv ...]',
epilog = 'Files must be listed after the output file and/or the option --fofn must be used. If both used, all files in the filename specified by --fofn AND the files listed after the output file will be used as input. The input report files must be in tsv format, not xls.')
parser.add_argument('-f', '--fofn', help='File of filenames of ariba reports in tsv format (not xls) to be summarised. Must be used if no input files listed after the outfile.', metavar='FILENAME')
parser.add_argument('--phandango', help='Write files that can be used as input to phandango, named with the given prefix. Writes a tree and csv file, which can be drag and dropped straight into JS Candy', metavar='files_prefix')
parser.add_argument('--phandango', help='Write files that can be used as input to phandango, named with the given prefix. Writes a tree and csv file, which can be drag and dropped straight into phandango', metavar='files_prefix')
parser.add_argument('--min_id', type=float, help='Minimum percent identity cutoff to count as assembled [%(default)s]', default=90, metavar='FLOAT')
parser.add_argument('--no_filter', action='store_true', help='Do not filter rows or columns of output that are all 0 (by default, they are removed from the output)')
parser.add_argument('outfile', help='Name of output file. If file ends with ".xls", then an excel spreadsheet is written. Otherwise a tsv file is written')
Expand Down
8 changes: 4 additions & 4 deletions ariba/tests/data/summary_test_write_phandango_csv.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name,seq1:z1,seq1;var.p.I14L:z2,seq1;var.p.P42Q:z2,seq2:z1,seq2;var.n.A14T:z2
file1,3,0,1,3,1
file2,3,1,0,3,0
name,seq1:o1,seq1;var.p.I14L:o1,seq1;var.p.P42Q:o1,seq2:o1,seq2;var.n.A14T:o1
file1,3,0,3,3,3
file2,3,3,0,3,0
file3,1,0,0,3,0
file4,2,1,0,0,0
file4,2,3,0,0,0
8 changes: 4 additions & 4 deletions ariba/tests/data/summary_test_write_phandango_files.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name,seq1:z1,seq1;var.p.I14L:z2,seq1;var.p.P42Q:z2,seq2:z1,seq2;var.n.A14T:z2
file1,3,0,1,3,1
file2,3,1,0,3,0
name,seq1:o1,seq1;var.p.I14L:o1,seq1;var.p.P42Q:o1,seq2:o1,seq2;var.n.A14T:o1
file1,3,0,3,3,3
file2,3,3,0,3,0
file3,1,0,0,3,0
file4,2,1,0,0,0
file4,2,3,0,0,0