Skip to content

Commit

Permalink
Merge pull request #124 from martinghunt/report_ref_base_assembled_bug
Browse files Browse the repository at this point in the history
Bug fix reporting ref_base_assembled for a partial gene assembly
  • Loading branch information
martinghunt authored Aug 16, 2016
2 parents b6d5ae7 + 9dc4405 commit 2473895
Show file tree
Hide file tree
Showing 7 changed files with 890 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ariba/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def _report_lines_for_one_contig(cluster, contig_name, ref_cov_per_contig, pymum
lines = []
contig_length = len(cluster.assembly.sequences[contig_name])
assert contig_length != 0

if contig_name in ref_cov_per_contig:
if contig_name == cluster.assembly_compare.scaff_name_matching_ref:
if contig_name == cluster.assembly_compare.scaff_name_matching_ref and cluster.assembly_compare.gene_matching_ref_type == 'GENE_FOUND':
ref_cov = len(cluster.ref_sequence)
else:
ref_cov = ref_cov_per_contig[contig_name]
Expand Down
17 changes: 17 additions & 0 deletions ariba/tests/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,20 @@ def test_full_run_cluster_test_full_run_smtls_snp_varonly_nonc(self):
]
self.assertEqual(expected, c.report_lines)
shutil.rmtree(tmpdir)


def test_full_run_partial_assembly(self):
'''Test complete run where only part of the ref gene is present in the reads'''
fasta_in = os.path.join(data_dir, 'cluster_test_full_run_partial_asmbly.fa')
tsv_in = os.path.join(data_dir, 'cluster_test_full_run_partial_asmbly.tsv')
refdata = reference_data.ReferenceData([fasta_in], [tsv_in])
tmpdir = 'tmp.cluster_test_full_run_partial_assembly'
shutil.copytree(os.path.join(data_dir, 'cluster_test_full_run_partial_asmbly'), tmpdir)
c = cluster.Cluster(tmpdir, 'cluster_name', refdata, spades_other_options='--only-assembler', total_reads=278, total_reads_bases=15020)
c.run()

expected = [
'presence_absence1\t1\t0\t19\t278\tcluster_name\t96\t77\t100.0\tcluster_name.scaffold.1\t949\t20.5\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\t.\tGeneric description of presence_absence1'
]
self.assertEqual(expected, c.report_lines)
shutil.rmtree(tmpdir)
3 changes: 3 additions & 0 deletions ariba/tests/data/cluster_test_full_run_partial_asmbly.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
>presence_absence1
ATGGATCGCGAAGCGATGACCCATGAAGCGACCGAACGCGCGAGCACCAACATTAGCCAT
ATTAACGGCATTAGCGCGTGGGAAAGCATGGAATAA
1 change: 1 addition & 0 deletions ariba/tests/data/cluster_test_full_run_partial_asmbly.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
presence_absence1 1 0 . . Generic description of presence_absence1
432 changes: 432 additions & 0 deletions ariba/tests/data/cluster_test_full_run_partial_asmbly/reads_1.fq

Large diffs are not rendered by default.

432 changes: 432 additions & 0 deletions ariba/tests/data/cluster_test_full_run_partial_asmbly/reads_2.fq

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
>presence_absence1
ATGGATCGCGAAGCGATGACCCATGAAGCGACCGAACGCGCGAGCACCAACATTAGCCAT
ATTAACGGCATTAGCGCGTGGGAAAGCATGGAATAA

0 comments on commit 2473895

Please sign in to comment.