Skip to content
Snippets Groups Projects
Commit 11eb9eec authored by Vermaat's avatar Vermaat
Browse files

Get only primary assembly mappings in position converter (naive fix for #58).

parent 57f3a404
No related branches found
No related tags found
No related merge requests found
...@@ -242,27 +242,34 @@ class Mapping(Db) : ...@@ -242,27 +242,34 @@ class Mapping(Db) :
@return: The version number @return: The version number
@rtype: integer @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 = """ q = """
select acc, select acc,
txStart, txEnd, txStart, txEnd,
cdsStart, cdsEnd, cdsStart, cdsEnd,
exonStarts, exonEnds, exonStarts, exonEnds,
geneName, chrom, geneName, chrom,
strand, protAcc, strand, protAcc
MAX(version)
from map from map
""" """
if version is None: if version is None:
q += """ q += """
where acc = %s; where acc = %s
version desc, order by chrom asc;
""" """
statement = (q, mrnaAcc) statement = (q, mrnaAcc)
else: else:
q += """ q += """
where acc = %s and where acc = %s and
version = %s; version = %s
order by chrom asc;
""" """
statement = q, (mrnaAcc, version) statement = q, (mrnaAcc, version)
......
...@@ -24,6 +24,8 @@ positions to I{g.} notation if the variant is in I{c.} notation or vice versa. ...@@ -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: Modules.Serializers.Transcript
@requires: Bio.Seq.reverse_complement @requires: Bio.Seq.reverse_complement
@requires: collections.defaultdict @requires: collections.defaultdict
@todo: Rename Mapper to converter?
""" """
import sys # argv import sys # argv
......
"""
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
...@@ -4,13 +4,8 @@ Tests for the variantchecker module. ...@@ -4,13 +4,8 @@ Tests for the variantchecker module.
#import logging; logging.basicConfig() #import logging; logging.basicConfig()
import re
import os
import random
from nose.tools import * from nose.tools import *
from Bio.Seq import Seq
import mutalyzer
from mutalyzer.config import Config from mutalyzer.config import Config
from mutalyzer.output import Output from mutalyzer.output import Output
from mutalyzer.variantchecker import check_variant from mutalyzer.variantchecker import check_variant
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment