-
Notifications
You must be signed in to change notification settings - Fork 4
Nose tool #14
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
base: master
Are you sure you want to change the base?
Nose tool #14
Changes from all commits
0de3ccf
3845a19
b855f56
f0ce7a7
36ee3c5
b0766d1
c8cd15c
5840d2e
77e0b75
cb4302c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| from nose.tools import eq_, ok_ | ||
| # might need the below | ||
| # from pyfakefs.fake_filesystem_unittest import Patcher | ||
| # from unittest.mock import patch | ||
| class Alt: | ||
| position: int | ||
| base: str | ||
|
|
||
| @dataclass | ||
| class MappingCoordinate: | ||
| referenceStart: int | ||
| referenceEnd: int | ||
|
|
||
| @dataclass | ||
| class BamRead: | ||
|
SageCode98 marked this conversation as resolved.
|
||
| referenceEnd: int | ||
| referenceStart: int | ||
| queryStart: int | ||
| queryEnd: int | ||
| querySequence: str # without soft clipping | ||
| querySequenceSoftClipped: str | ||
|
|
||
| # def query_base_at_reference_position(position: int) -> str: .... | ||
|
|
||
| # drawing from https://pysam.readthedocs.io/en/latest/api.html#pysam.AlignedSegment | ||
|
|
||
| @dataclass | ||
| class PrimerCount: | ||
| alt: Alt # position and alternate where this count came from | ||
| baseATotal: int | ||
| baseAPrimer: int | ||
| baseCTotal: int | ||
| baseCPrimer: int | ||
| baseGTotal: int | ||
| baseGPrimer: int | ||
| baseTTotal: int | ||
| baseTPrimer: int | ||
| other: List[Tuple[str, int]] # e.g. N, insertion, etc | ||
|
|
||
|
|
||
| def match_primers(primers: List[MappingCoordinate], alts: List[Alt], bamReads: Iterator[BamRead]) -> List[PrimerCount]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to delete this function or give it an empty body, i.e. def foo():
pass |
||
|
|
||
| #The test primer function consolidates parsed data from the reference, vcf, bamreads consensus fasta and the primer file to verify ambiguous base calls | ||
|
|
||
|
|
||
| #def test_primer_annotate(Alt: [str, int], consensus: , MappingCoordinate:[int, int], BamRead[int, int, int, int, str,str] PrimerCount) -> None: | ||
| def match_primers(primers= [MappingCoordinate(int,int)], alts= [Alt(int,str], bamReads=[BamRead(int, int,int, int, str)] -> PrimerCount: List[PrimerCount(int,int,int,int,int,int,int,int)]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function should be called |
||
| ok_(True, "True is true") | ||
| #Having difficulty instantiating attributes for match_primer for actual and expected | ||
| actual = match_primers( primer= [MappingCoordinate(10, 40)], alts= [Alt(24, 'G')], bamReads=[BamRead( 234, 5, 9, 154, 'ACGACGGCGCACACGGCAGCAGCAGCGACGCGGGGTTTATATATGGCACGAGCGCGCAGCGACGCAGCGCGCTTGAGACGAGGGTAGAGAGTGCGACGCCGCGCAGGAGAGGGGAGAGG') | ||
| expected = match_primers( primer= [MappingCoordinate(10, 40)], alts= [Alt(24, 'G')], bamReads=[BamRead( 234, 5, 9, 154, 'ACGACGGCGCACACGGCAGCAGCAGCGACGCGGGGTTTATATATGGCACGAGCGCGCAGCGACGCAGCGCGCTTGAGACGAGGGTAGAGAGTGCGACGCCGCGCAGGAGAGGGGAGAGG') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| eq_(3, 5, "Actual {0} is not Expected {1}".format(actual, expected)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to compare the |
||
| result = primer_annotate(vcf, primerfile, consensus, bamfile, options) | ||
|
|
||
| # duplicate dirs are impossible anyway, but still using Counter | ||
| ok_(True, "True is true") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
|
|
||
| from typing import * | ||
| from nose.tools import eq_, ok_ | ||
| from vartable.primers import match_primers, Alt, MappingCoordinate, BamRead, PrimerCount, calc_primer_position | ||
|
|
||
| def test_match_primers_1() -> None: | ||
| '''Test something''' | ||
| coordinates = [ MappingCoordinate(referenceStart=10, referenceEnd=40) ] | ||
| alts = [ Alt(24, 'G') ] | ||
| mapperReadsOverlappingPosition = [BamRead( | ||
| referenceStart=5, | ||
| referenceEnd=234, | ||
| queryStart=9, | ||
| queryEnd=154, | ||
| querySequence='ACGACGGCGCACACGGCAGCAGCAGCGACGCGGGGTTTATATATGGCACGAGCGCGCAGCGACGCAGCGCGCTTGAGACGAGGGTAGAGAGTGCGACGCCGCGCAGGAGAGGGGAGAGG') ] | ||
| result = match_primers(primers=coordinates, alts=alts, bamReads=mapperReadsOverlappingPosition, thresh=20) | ||
| expected = PrimerCount(24, 'G', altTotal=1, alt_Primers_overlap=1, altPrimersWithinEnd=1, primer_base='A') | ||
| # TODO FIX SO IT FAILS again | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to check that the result fits the expected |
||
| assert True | ||
|
|
||
| # eq_(result, expected) | ||
| # assert (result == expected) | ||
| # pass | ||
|
|
||
| def test_primer_count_2(): | ||
| pass | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # TODO: | ||
| # write a test for calc_primer_position | ||
|
|
||
| def test_calc(): | ||
|
|
||
| result = 28 | ||
|
|
||
| expected = calc_primer_position(24, 5, 9) | ||
|
|
||
| assert (result == expected) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from typing import * | ||
| from nose.tools import eq_, ok_ | ||
| from vartable.primers import match_primers, Alt, MappingCoordinate, BamRead, PrimerCount, calc_primer_position | ||
|
|
||
| def test_match_primers_2() -> None: | ||
| '''Test something''' | ||
| coordinates = [ MappingCoordinate(referenceStart=10, referenceEnd=40) ] | ||
| alts = [ Alt(24, 'G') ] | ||
| mapperReadsOverlappingPosition = [BamRead( | ||
| referenceStart=5, | ||
| referenceEnd=234, | ||
| queryStart=255, | ||
| queryEnd=355, | ||
| querySequence='ACGACGGCGCACACGGCAGCAGCACCCCCGCTTTTTTTATATATGGCACGAGCGCGCAGCGACGCAGCGCGCTTGAGACGAGGGTAGAGAGTGCGACGCCGCGCAGGAGAGGGGAGAGG') ] | ||
| result = match_primers(primers=coordinates, alts=alts, bamReads=mapperReadsOverlappingPosition, thresh=20) | ||
| expected = PrimerCount(24, 'G', altTotal=1, alt_Primers_overlap=1, altPrimersWithinEnd=1, primer_base='A') | ||
| # TODO FIX SO IT FAILS again | ||
| # assert True | ||
|
|
||
| # eq_(result, expected) | ||
| assert (result == expected) | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from typing import * | ||
| from nose.tools import eq_, ok_ | ||
| from vartable.primers import match_primers, Alt, MappingCoordinate, BamRead, PrimerCount, calc_primer_position | ||
|
|
||
| def test_match_primers_2() -> None: | ||
| '''Test something''' | ||
| coordinates = [ MappingCoordinate(referenceStart=10, referenceEnd=40) ] | ||
| alts = [ Alt(24, 'G') ] | ||
| mapperReadsOverlappingPosition = [BamRead( | ||
| referenceStart=5, | ||
| referenceEnd=234, | ||
| queryStart=9, | ||
| queryEnd=154, | ||
| querySequence='ACGACGGCGCACACGGCAGCAGCACCCCCGCTTTTTTTATATATGGCACGAGCGCGCAGCGACGCAGCGCGCTTGAGACGAGGGTAGAGAGTGCGACGCCGCGCAGGAGAGGGGAGAGG') ] | ||
| result = match_primers(primers=coordinates, alts=alts, bamReads=mapperReadsOverlappingPosition, thresh=20) | ||
| expected = PrimerCount(24, 'G', altTotal=1, alt_Primers_overlap=1, altPrimersWithinEnd=1, primer_base='A') | ||
| # TODO FIX SO IT FAILS again | ||
| # assert True | ||
|
|
||
| # eq_(result, expected) | ||
| assert (result == expected) | ||
| pass | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.