Skip to content

Commit

Permalink
Merge pull request #8 from simpsonlab/fix_lineage_notes
Browse files Browse the repository at this point in the history
Fix lineage notes
  • Loading branch information
rdeborja authored May 31, 2021
2 parents e75ae6f + 118b65e commit 56ec492
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
The `ncov_parser` package provides a suite of tools to parse the files generated
in the Nextflow workflow and provide a QC summary file. The package requires
several files including:
* <sample>.variants.tsv/<sample>.pass.vcf
* <sample>.variants.tsv
* <sample>.variants.norm.vcf
* <sample>.pass.vcf
* <sample>.per_base_coverage.bed
* <sample>.primertrimmed.consensus.fa
* <sample>.consensus.fasta
* alleles.tsv

An optional metadata file with qPCR ct and collection date values can be
Expand Down
4 changes: 4 additions & 0 deletions data/test_lineages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
taxon,lineage,conflict,ambiguity_score,scorpio_call,scorpio_support,scorpio_conflict,version,pangolin_version,pangoLEARN_version,pango_version,status,note
sampleA,B.1.1.7,0.0,1.0,cB.1.1.7,0.782600,0.130400,PLEARN-v1.2.6,3.0.3,2021-05-27,v1.2.6,passed_qc,scorpio call: Alt alleles 18; Ref alleles 3; Amb alleles 0
sampleB,B.1.1.7,0.0,1.0,cB.1.1.7,0.652200,0.130400,PLEARN-v1.2.6,3.0.3,2021-05-27,v1.2.6,passed_qc,scorpio call: Alt alleles 15; Ref alleles 3; Amb alleles 3
sampleC,B.1.1.7,0.0,1.0,cB.1.1.7,0.782600,0.130400,PLEARN-v1.2.6,3.0.3,2021-05-27,v1.2.6,passed_qc,scorpio call: Alt alleles 18; Ref alleles 3; Amb alleles 0
7 changes: 6 additions & 1 deletion ncov/parser/Lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def get_notes(self, row):
if n is None or n == "":
return "none"
else:
return n.replace(" ", "_")
n_dict = n.split(' ')
alt = re.sub(';', '', n_dict[4])
ref = re.sub(';', '', n_dict[7])
amb = n_dict[-1]
return '/'.join([alt, ref, amb])
#return n.replace(" ", "_")

def create_lineage_dictionary(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="ncov_parser",
version="0.6.5",
version="0.6.6",
author="Richard J. de Borja",
author_email="[email protected]",
description="A nCoV package for parsing analysis files",
Expand Down
7 changes: 4 additions & 3 deletions tests/test_Lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import unittest
import ncov.parser

test_lineage = ncov.parser.Lineage(file='data/sample_lineages.csv')
test_lineage = ncov.parser.Lineage(file='data/test_lineages.csv')


class LineageTest(unittest.TestCase):
def test_create_lineage_dictionary(self):
lineage_dict = test_lineage.create_lineage_dictionary()
self.assertEqual(lineage_dict['sampleA']['lineage'], 'B.1.1.43')
self.assertEqual(lineage_dict['sampleB']['lineage'], 'B.1.36')
self.assertEqual(lineage_dict['sampleA']['lineage'], 'B.1.1.7')
self.assertEqual(lineage_dict['sampleA']['notes'], '18/3/0')
self.assertEqual(lineage_dict['sampleB']['lineage'], 'B.1.1.7')
self.assertEqual(lineage_dict['sampleC']['lineage'], 'B.1.1.7')
def test_get_sample_name(self):
sample_row = {'taxon' : 'sampleA/ARTIC/nanopolish',
Expand Down

0 comments on commit 56ec492

Please sign in to comment.