diff --git a/mutalyzer/Db.py b/mutalyzer/Db.py index b608cffbd9a16f047ed5e3e7457784e97674eded..18e8237e9a988af06cef5d49ecdf325b4222fa89 100644 --- a/mutalyzer/Db.py +++ b/mutalyzer/Db.py @@ -242,27 +242,34 @@ class Mapping(Db) : @return: The version number @rtype: integer - """ + @todo: The 'order by chrom asc' is a quick hack to make sure we first + get a primary assembly mapping instead of some haplotype mapping + for genes in the HLA cluster. + A better fix is to return the entire list of mappings, and/or + remove all secondary mappings for the HLA cluster. + See also test_converter.test_hla_cluster and bug #58. + """ q = """ select acc, txStart, txEnd, cdsStart, cdsEnd, exonStarts, exonEnds, geneName, chrom, - strand, protAcc, - MAX(version) + strand, protAcc from map """ if version is None: q += """ - where acc = %s; + where acc = %s + version desc, order by chrom asc; """ statement = (q, mrnaAcc) else: q += """ where acc = %s and - version = %s; + version = %s + order by chrom asc; """ statement = q, (mrnaAcc, version) diff --git a/mutalyzer/Mapper.py b/mutalyzer/Mapper.py index 0138e7e2e8feb6e506a1a2fd0fe8d5759a1d3e27..ef09e108c1080d69f09479fcc1e8fcd4ad840300 100644 --- a/mutalyzer/Mapper.py +++ b/mutalyzer/Mapper.py @@ -24,6 +24,8 @@ positions to I{g.} notation if the variant is in I{c.} notation or vice versa. @requires: Modules.Serializers.Transcript @requires: Bio.Seq.reverse_complement @requires: collections.defaultdict + +@todo: Rename Mapper to converter? """ import sys # argv diff --git a/tests/test_converter.py b/tests/test_converter.py new file mode 100644 index 0000000000000000000000000000000000000000..17d4c5c575add0080a577e3ad9a4b2cd68cabf48 --- /dev/null +++ b/tests/test_converter.py @@ -0,0 +1,54 @@ +""" +Tests for the converter (Mapper) module. +""" + + +#import logging; logging.basicConfig() +from nose.tools import * + +from mutalyzer.config import Config +from mutalyzer.output import Output +from mutalyzer.Mapper import Converter + + +class TestConverter(): + """ + Test the converter (Mapper) module. + """ + def setUp(self): + """ + Initialize test converter module. + """ + self.config = Config() + self.output = Output(__file__, self.config.Output) + + def _converter(self, build): + """ + Create a Converter instance for a given build. + """ + return Converter(build, self.config, self.output) + + def test_converter(self): + """ + Simple test. + """ + converter = self._converter('hg19') + genomic = converter.c2chrom('NM_003002.2:c.274G>T') + assert_equal(genomic, 'NC_000011.9:g.111959695G>T') + coding = converter.chrom2c(genomic, 'list') + assert 'NM_003002.2:c.274G>T' in coding + + def test_hla_cluster(self): + """ + Convert to primary assembly. + + Transcript NM_000500.5 is mapped to different chromosome locations, + but we like to just see the primary assembly mapping to chromosome 6. + + See also bug #58. + """ + converter = self._converter('hg19') + genomic = converter.c2chrom('NM_000500.5:c.92C>T') + assert_equal(genomic, 'NC_000006.11:g.32006291C>T') + coding = converter.chrom2c(genomic, 'list') + assert 'NM_000500.5:c.92C>T' in coding diff --git a/tests/test_variantchecker.py b/tests/test_variantchecker.py index 69f9a55210024e944cfff52e872eacc6df8fb2a7..74bbae733b93b4caadcb097559de70ffa3b211fc 100644 --- a/tests/test_variantchecker.py +++ b/tests/test_variantchecker.py @@ -4,13 +4,8 @@ Tests for the variantchecker module. #import logging; logging.basicConfig() -import re -import os -import random from nose.tools import * -from Bio.Seq import Seq -import mutalyzer from mutalyzer.config import Config from mutalyzer.output import Output from mutalyzer.variantchecker import check_variant