Commit 1287cabc authored by Laros's avatar Laros
Browse files

Isolated crossmapper module.

New module can be found here:

    https://github.com/mutalyzer/crossmapper
parent 1b1ccc34
...@@ -628,8 +628,9 @@ Other wrapper functions in this class only call the wrappers described above. ...@@ -628,8 +628,9 @@ Other wrapper functions in this class only call the wrappers described above.
Finally, there are a couple of functions that offer more information of a Finally, there are a couple of functions that offer more information of a
transcript; an \texttt{info()} function that gives information about transcript; an \texttt{info()} function that gives information about
transcription start, transcription stop and CDS stop, a function transcription start, transcription stop and CDS stop, a function
\texttt{getSpliceSite()} that returns the genomic coordinate of a splice site \texttt{get\_splice\_site()} that returns the genomic coordinate of a splice
(indexed by rank), and functions that return the number of introns and exons. site (indexed by rank), and functions that return the number of introns and
exons.
\newpage \newpage
......
This diff is collapsed.
...@@ -17,8 +17,9 @@ search for them each time. ...@@ -17,8 +17,9 @@ search for them each time.
from __future__ import unicode_literals from __future__ import unicode_literals
from crossmapper.crossmapper import Crossmap
from mutalyzer import util from mutalyzer import util
from mutalyzer import Crossmap
SPLICE_ALARM = 2 SPLICE_ALARM = 2
...@@ -614,14 +615,13 @@ class GenRecord() : ...@@ -614,14 +615,13 @@ class GenRecord() :
j.transcribe = True j.transcribe = True
j.translate = True j.translate = True
#if #if
j.CM = Crossmap.Crossmap(j.mRNA.positionList, j.CM = Crossmap(
j.CDS.location, i.orientation) j.mRNA.positionList, j.CDS.location, i.orientation)
#if #if
else : else :
j.molType = 'n' j.molType = 'n'
if j.mRNA.positionList : if j.mRNA.positionList :
j.CM = Crossmap.Crossmap(j.mRNA.positionList, j.CM = Crossmap(j.mRNA.positionList, [], i.orientation)
[], i.orientation)
j.transcribe = True j.transcribe = True
else : else :
j.description = '?' j.description = '?'
...@@ -773,7 +773,7 @@ class GenRecord() : ...@@ -773,7 +773,7 @@ class GenRecord() :
# care in variantchecker.py. # care in variantchecker.py.
if not j.current and \ if not j.current and \
util.over_splice_site(orientedStart, orientedStop, util.over_splice_site(orientedStart, orientedStop,
j.CM.RNA): j.CM.rna):
j.translate = False j.translate = False
# And check whether the variant hits CDS start. # And check whether the variant hits CDS start.
......
...@@ -19,12 +19,13 @@ from operator import attrgetter, itemgetter ...@@ -19,12 +19,13 @@ from operator import attrgetter, itemgetter
import binning import binning
import MySQLdb import MySQLdb
from crossmapper.crossmapper import Crossmap
from mutalyzer.db import session from mutalyzer.db import session
from mutalyzer.db.models import Chromosome, TranscriptMapping from mutalyzer.db.models import Chromosome, TranscriptMapping
from mutalyzer.grammar import Grammar from mutalyzer.grammar import Grammar
from mutalyzer.models import SoapMessage, Mapping, Transcript from mutalyzer.models import SoapMessage, Mapping, Transcript
from mutalyzer.output import Output from mutalyzer.output import Output
from mutalyzer import Crossmap
from mutalyzer import Retriever from mutalyzer import Retriever
from mutalyzer import util from mutalyzer import util
...@@ -272,7 +273,7 @@ class Converter(object) : ...@@ -272,7 +273,7 @@ class Converter(object) :
cds = self.mapping.cds or [] cds = self.mapping.cds or []
orientation = 1 if self.mapping.orientation == 'forward' else -1 orientation = 1 if self.mapping.orientation == 'forward' else -1
self.crossmap = Crossmap.Crossmap(mrna, cds, orientation) self.crossmap = Crossmap(mrna, cds, orientation)
return self.crossmap return self.crossmap
#makeCrossmap #makeCrossmap
...@@ -297,14 +298,14 @@ class Converter(object) : ...@@ -297,14 +298,14 @@ class Converter(object) :
if Type in 'cn' : if Type in 'cn' :
if Loc.IVSLoc: if Loc.IVSLoc:
ivs_number = int(Loc.IVSLoc.IVSNumber) ivs_number = int(Loc.IVSLoc.IVSNumber)
if ivs_number < 1 or ivs_number > C.numberOfIntrons(): if ivs_number < 1 or ivs_number > C.number_of_introns():
# Todo: Error handling in this entire module is 'suboptimal' # Todo: Error handling in this entire module is 'suboptimal'
raise Exception('Invalid intron') raise Exception('Invalid intron')
if Loc.IVSLoc.OffSgn == '+': if Loc.IVSLoc.OffSgn == '+':
g = C.getSpliceSite(ivs_number * 2 - 1) + \ g = C.get_splice_site(ivs_number * 2 - 1) + \
C.orientation * int(Loc.IVSLoc.Offset) C.orientation * int(Loc.IVSLoc.Offset)
else: else:
g = C.getSpliceSite(ivs_number * 2) - \ g = C.get_splice_site(ivs_number * 2) - \
C.orientation * int(Loc.IVSLoc.Offset) C.orientation * int(Loc.IVSLoc.Offset)
main, offset = C.g2x(g) main, offset = C.g2x(g)
else: else:
...@@ -764,7 +765,7 @@ class Converter(object) : ...@@ -764,7 +765,7 @@ class Converter(object) :
# mtype = 'n' # mtype = 'n'
#else : #else :
# mtype = 'c' # mtype = 'c'
if self.crossmap.CDS: if self.crossmap.cds:
mtype = 'c' mtype = 'c'
else: else:
mtype = 'n' mtype = 'n'
......
...@@ -1117,13 +1117,13 @@ class MutalyzerService(ServiceBase): ...@@ -1117,13 +1117,13 @@ class MutalyzerService(ServiceBase):
# - transcript.mRNA.positionList: splice sites (g) # - transcript.mRNA.positionList: splice sites (g)
t.exons = [] t.exons = []
for i in range(0, transcript.CM.numberOfExons() * 2, 2): for i in range(0, transcript.CM.number_of_exons() * 2, 2):
exon = ExonInfo() exon = ExonInfo()
exon.gStart = transcript.CM.getSpliceSite(i) exon.gStart = transcript.CM.get_splice_site(i)
exon.cStart = transcript.CM.g2c(exon.gStart) exon.cStart = transcript.CM.g2c(exon.gStart)
exon.chromStart = GenRecordInstance.record.toChromPos( exon.chromStart = GenRecordInstance.record.toChromPos(
exon.gStart) exon.gStart)
exon.gStop = transcript.CM.getSpliceSite(i + 1) exon.gStop = transcript.CM.get_splice_site(i + 1)
exon.cStop = transcript.CM.g2c(exon.gStop) exon.cStop = transcript.CM.g2c(exon.gStop)
exon.chromStop = GenRecordInstance.record.toChromPos( exon.chromStop = GenRecordInstance.record.toChromPos(
exon.gStop) exon.gStop)
......
...@@ -100,7 +100,7 @@ def _check_intronic_position(main, offset, transcript): ...@@ -100,7 +100,7 @@ def _check_intronic_position(main, offset, transcript):
@todo: Check if the offset is really in the flanking intron. @todo: Check if the offset is really in the flanking intron.
""" """
main_g = transcript.CM.x2g(main, 0) main_g = transcript.CM.x2g(main, 0)
sites = transcript.CM.RNA sites = transcript.CM.rna
if offset: if offset:
oriented_offset = offset * transcript.CM.orientation oriented_offset = offset * transcript.CM.orientation
...@@ -760,14 +760,14 @@ def _intronic_to_genomic(location, transcript): ...@@ -760,14 +760,14 @@ def _intronic_to_genomic(location, transcript):
""" """
ivs_number = int(location.IVSNumber) ivs_number = int(location.IVSNumber)
if ivs_number < 1 or ivs_number > transcript.CM.numberOfIntrons(): if ivs_number < 1 or ivs_number > transcript.CM.number_of_introns():
raise _InvalidIntronError(ivs_number) raise _InvalidIntronError(ivs_number)
if location.OffSgn == '+': if location.OffSgn == '+':
return transcript.CM.getSpliceSite(ivs_number * 2 - 1) + \ return transcript.CM.get_splice_site(ivs_number * 2 - 1) + \
transcript.CM.orientation * int(location.Offset) transcript.CM.orientation * int(location.Offset)
else: else:
return transcript.CM.getSpliceSite(ivs_number * 2) - \ return transcript.CM.get_splice_site(ivs_number * 2) - \
transcript.CM.orientation * int(location.Offset) transcript.CM.orientation * int(location.Offset)
#_intronic_to_genomic #_intronic_to_genomic
...@@ -792,17 +792,17 @@ def _exonic_to_genomic(location, transcript) : ...@@ -792,17 +792,17 @@ def _exonic_to_genomic(location, transcript) :
flanking exons. flanking exons.
""" """
first_exon = int(location.EXNumberStart) first_exon = int(location.EXNumberStart)
if first_exon < 1 or first_exon > transcript.CM.numberOfExons(): if first_exon < 1 or first_exon > transcript.CM.number_of_exons():
raise _InvalidExonError(first_exon) raise _InvalidExonError(first_exon)
first = transcript.CM.getSpliceSite(first_exon * 2 - 2) first = transcript.CM.get_splice_site(first_exon * 2 - 2)
if location.EXNumberStop: if location.EXNumberStop:
last_exon = int(location.EXNumberStop) last_exon = int(location.EXNumberStop)
if last_exon < 1 or last_exon > transcript.CM.numberOfExons(): if last_exon < 1 or last_exon > transcript.CM.number_of_exons():
raise _InvalidExonError(last_exon) raise _InvalidExonError(last_exon)
last = transcript.CM.getSpliceSite(last_exon * 2 - 1) last = transcript.CM.get_splice_site(last_exon * 2 - 1)
else: else:
last = transcript.CM.getSpliceSite(first_exon * 2 - 1) last = transcript.CM.get_splice_site(first_exon * 2 - 1)
return first, last return first, last
#_exonic_to_genomic #_exonic_to_genomic
...@@ -873,13 +873,13 @@ def _coding_to_genomic(first_location, last_location, transcript, output): ...@@ -873,13 +873,13 @@ def _coding_to_genomic(first_location, last_location, transcript, output):
first_location.Main) first_location.Main)
first_main_genomic = transcript.CM.x2g(first_main, 0) first_main_genomic = transcript.CM.x2g(first_main, 0)
first_offset = _get_offset(first_location, first_main_genomic, first_offset = _get_offset(first_location, first_main_genomic,
transcript.CM.RNA, output) transcript.CM.rna, output)
last_main = transcript.CM.main2int(last_location.MainSgn + \ last_main = transcript.CM.main2int(last_location.MainSgn + \
last_location.Main) last_location.Main)
last_main_genomic = transcript.CM.x2g(last_main, 0) last_main_genomic = transcript.CM.x2g(last_main, 0)
last_offset = _get_offset(last_location, last_main_genomic, last_offset = _get_offset(last_location, last_main_genomic,
transcript.CM.RNA, output) transcript.CM.rna, output)
# These raise _RawVariantError exceptions on invalid positions. # These raise _RawVariantError exceptions on invalid positions.
_check_intronic_position(first_main, first_offset, transcript) _check_intronic_position(first_main, first_offset, transcript)
...@@ -1089,7 +1089,7 @@ def process_raw_variant(mutator, variant, record, transcript, output): ...@@ -1089,7 +1089,7 @@ def process_raw_variant(mutator, variant, record, transcript, output):
# If we hit a splice site, issue a warning. Later on we decide if we # If we hit a splice site, issue a warning. Later on we decide if we
# can still process this variant in any way (e.g. if it deletes an # can still process this variant in any way (e.g. if it deletes an
# entire exon). # entire exon).
if transcript and util.over_splice_site(first, last, transcript.CM.RNA): if transcript and util.over_splice_site(first, last, transcript.CM.rna):
splice_abort = True splice_abort = True
output.addMessage(__file__, 2, 'WOVERSPLICE', output.addMessage(__file__, 2, 'WOVERSPLICE',
'Variant hits one or more splice sites in ' \ 'Variant hits one or more splice sites in ' \
...@@ -1104,7 +1104,7 @@ def process_raw_variant(mutator, variant, record, transcript, output): ...@@ -1104,7 +1104,7 @@ def process_raw_variant(mutator, variant, record, transcript, output):
# NM_000088.3(COL1A1_v001):c.588del # NM_000088.3(COL1A1_v001):c.588del
if transcript and variant.MutationType == 'del': if transcript and variant.MutationType == 'del':
removed_sites = [] removed_sites = []
for acceptor, donor in util.grouper(transcript.CM.RNA): for acceptor, donor in util.grouper(transcript.CM.rna):
# If we have introns, we match splice sites in a fuzzy way. This # If we have introns, we match splice sites in a fuzzy way. This
# Means that in the case of # Means that in the case of
...@@ -1141,7 +1141,7 @@ def process_raw_variant(mutator, variant, record, transcript, output): ...@@ -1141,7 +1141,7 @@ def process_raw_variant(mutator, variant, record, transcript, output):
# Todo: We might cripple the start codon, fix the translation code # Todo: We might cripple the start codon, fix the translation code
# (further down) to deal with this. # (further down) to deal with this.
# Todo: Bit unrelated, but find out the difference between # Todo: Bit unrelated, but find out the difference between
# - transcript.CM.RNA # - transcript.CM.rna
# - transcript.mRNA.positionList # - transcript.mRNA.positionList
# and what we should use (likewise for CDS). # and what we should use (likewise for CDS).
removed_cds_sites = filter(lambda s: s in transcript.CDS.positionList, removed_cds_sites = filter(lambda s: s in transcript.CDS.positionList,
...@@ -1279,9 +1279,9 @@ def _add_static_transcript_info(transcript, output): ...@@ -1279,9 +1279,9 @@ def _add_static_transcript_info(transcript, output):
output.addOutput('hasTranscriptInfo', True) output.addOutput('hasTranscriptInfo', True)
# Add exon table to output. # Add exon table to output.
for i in range(0, transcript.CM.numberOfExons() * 2, 2): for i in range(0, transcript.CM.number_of_exons() * 2, 2):
acceptor = transcript.CM.getSpliceSite(i) acceptor = transcript.CM.get_splice_site(i)
donor = transcript.CM.getSpliceSite(i + 1) donor = transcript.CM.get_splice_site(i + 1)
output.addOutput('exonInfo', [acceptor, donor, output.addOutput('exonInfo', [acceptor, donor,
transcript.CM.g2c(acceptor), transcript.CM.g2c(acceptor),
transcript.CM.g2c(donor)]) transcript.CM.g2c(donor)])
...@@ -1296,7 +1296,7 @@ def _add_static_transcript_info(transcript, output): ...@@ -1296,7 +1296,7 @@ def _add_static_transcript_info(transcript, output):
# Is this transcript coding? # Is this transcript coding?
# Example of non-coding transcript variant: # Example of non-coding transcript variant:
# AL449423.14(CDKN2A_v004):n.42_437del # AL449423.14(CDKN2A_v004):n.42_437del
output.addOutput('transcriptCoding', bool(transcript.CM.CDS)) output.addOutput('transcriptCoding', bool(transcript.CM.cds))
# Is this transcript on the reverse strand? # Is this transcript on the reverse strand?
output.addOutput('transcriptReverse', transcript.CM.orientation == -1) output.addOutput('transcriptReverse', transcript.CM.orientation == -1)
......
...@@ -27,3 +27,4 @@ spyne==2.12.11 ...@@ -27,3 +27,4 @@ spyne==2.12.11
suds==0.4 suds==0.4
wsgiref==0.1.2 wsgiref==0.1.2
xlrd==0.9.4 xlrd==0.9.4
git+https://github.com/mutalyzer/crossmapper.git
"""
Tests for the mutalyzer.Crossmap module.
"""
from __future__ import unicode_literals
from mutalyzer.Crossmap import Crossmap
def test_splice_sites():
"""
Check whether the gene on the forward strand has the right splice
sites in c. notation.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cds = [27925, 74736]
cm = Crossmap(rna, cds, 1)
assert (cm._Crossmap__crossmapping ==
[-304, -181, -180, 15, 16, 117, 118, 205, 206, 325, 326, 398,
399, 522, 523, 1320])
def test_splice_sites_reverse():
"""
Check whether the gene on the reverse strand has the right splice
sites in c. notation.
"""
rna = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
cds = [76479, 123290]
cm = Crossmap(rna, cds, -1)
assert (cm._Crossmap__crossmapping ==
[1320, 523, 522, 399, 398, 326, 325, 206, 205, 118, 117, 16,
15, -180, -181, -304])
def test_g2x():
"""
Do some g. to c. conversion checking for the gene on the forward
strand.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cds = [27925, 74736]
cm = Crossmap(rna, cds, 1)
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(5001)) == '-304-u1'
assert cm.tuple2string(cm.g2x(5001)) == '-305'
assert cm.tuple2string(cm.g2x(5124)) == '-182'
assert cm.tuple2string(cm.g2x(5126)) == '-181+1'
assert cm.tuple2string(cm.g2x(27924)) == '-1'
assert cm.tuple2string(cm.g2x(27925)) == '1'
assert cm.tuple2string(cm.g2x(58660)) == '16-1'
assert cm.tuple2string(cm.g2x(74736)) == '174'
assert cm.tuple2string(cm.g2x(74737)) == '*1'
assert cm.tuple2string(cm.g2x(103408)) == '*32-1'
assert cm.tuple2string(cm.g2x(103410)) == '*33'
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(149216)) == '*1146+d1'
assert cm.tuple2string(cm.g2x(149216)) == '*1147'
def test_g2x_reverse():
"""
Do some g. to c. conversion checking for the gene on the reverse
strand.
"""
rna = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
cds = [76479, 123290]
cm = Crossmap(rna, cds, -1)
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(146214)) == '-304-u1'
assert cm.tuple2string(cm.g2x(146214)) == '-305'
assert cm.tuple2string(cm.g2x(146091)) == '-182'
assert cm.tuple2string(cm.g2x(146089)) == '-181+1'
assert cm.tuple2string(cm.g2x(123291)) == '-1'
assert cm.tuple2string(cm.g2x(123290)) == '1'
assert cm.tuple2string(cm.g2x(92555)) == '16-1'
assert cm.tuple2string(cm.g2x(76479)) == '174'
assert cm.tuple2string(cm.g2x(76478)) == '*1'
assert cm.tuple2string(cm.g2x(47807)) == '*32-1'
assert cm.tuple2string(cm.g2x(47805)) == '*33'
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(1999)) == '*1146+d1'
assert cm.tuple2string(cm.g2x(1999)) == '*1147'
def test_x2g_more():
"""
Do some c. to g. conversion checking for the gene on the forward
strand.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cds = [27925, 74736]
cm = Crossmap(rna, cds, 1)
assert cm.x2g(-304, -1) == 5001
assert cm.x2g(-182, 0) == 5124
assert cm.x2g(-181, 1) == 5126
assert cm.x2g(-1, 0) == 27924
assert cm.x2g(1, 0) == 27925
assert cm.x2g(16, -1) == 58660
assert cm.x2g(174, 0) == 74736
assert cm.x2g(cm.main2int('*1'), 0) == 74737
assert cm.x2g(cm.main2int('*32'), -1) == 103408
assert cm.x2g(cm.main2int('*33'), 0) == 103410
assert cm.x2g(cm.main2int('*1146'), 1) == 149216
def test_x2g_more_reverse():
"""
Do some c. to g. conversion checking for the gene on the reverse
strand.
"""
rna = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
cds = [76479, 123290]
cm = Crossmap(rna, cds, -1)
assert cm.x2g(-304, -1) == 146214
assert cm.x2g(-182, 0) == 146091
assert cm.x2g(-181, 1) == 146089
assert cm.x2g(-1, 0) == 123291
assert cm.x2g(1, 0) == 123290
assert cm.x2g(16, -1) == 92555
assert cm.x2g(174, 0) == 76479
assert cm.x2g(cm.main2int('*1'), 0) == 76478
assert cm.x2g(cm.main2int('*32'), -1) == 47807
assert cm.x2g(cm.main2int('*33'), 0) == 47805
assert cm.x2g(cm.main2int('*1146'), 1) == 1999
def test_g2x_missing_exons():
"""
Hypothetical gene, missing the first exon and the last two exons
should have the same crossmapping on the shared part.
"""
rna1 = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
rna2 = [27745, 27939, 58661, 58762, 74680, 74767, 103409, 103528,
119465, 119537]
cds = [27925, 74736]
cm1 = Crossmap(rna1, cds, 1)
cm2 = Crossmap(rna2, cds, 1)
assert cm1.g2x(27925) == cm2.g2x(27925)
def test_g2x_missing_exons_reverse():
"""
Hypothetical gene on the reverse strand, missing the first exon and
the last two exons should have the same crossmapping on the shared
part.
"""
rna1 = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
rna2 = [31678, 31750, 47687, 47806, 76448, 76535, 92453, 92554,
123276, 123470]
cds = [76479, 123290]
cm1 = Crossmap(rna1, cds, -1)
cm2 = Crossmap(rna2, cds, -1)
assert cm1.g2x(123290) == cm2.g2x(123290)
def test_splice_sites_noncoding():
"""
Check whether the gene on the forward strand has the right splice
sites in n. notation.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cm = Crossmap(rna, [], 1)
assert (cm._Crossmap__crossmapping ==
[1, 124, 125, 319, 320, 421, 422, 509, 510, 629, 630, 702,
703, 826, 827, 1624])
def test_splice_sites_noncoding_reverse():
"""
Check whether the gene on the reverse strand has the right splice
sites in n. notation.
"""
rna = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
cm = Crossmap(rna, [], -1)
assert (cm._Crossmap__crossmapping ==
[1624, 827, 826, 703, 702, 630, 629, 510, 509, 422, 421, 320,
319, 125, 124, 1])
def test_g2x_noncoding():
"""
Do some g. to n. conversion checking for the gene on the forward
strand.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cm = Crossmap(rna, [], 1)
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(5001)) == '1-u1'
assert cm.tuple2string(cm.g2x(5001)) == '-1'
assert cm.tuple2string(cm.g2x(5002)) == '1'
assert cm.tuple2string(cm.g2x(5126)) == '124+1'
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(149216)) == '1624+d1'
assert cm.tuple2string(cm.g2x(149216)) == '*1'
def test_g2x_noncoding_reverse():
"""
Do some g. to n. conversion checking for the gene on the reverse
strand.
"""
rna = [2000, 2797, 6405, 6528, 31678, 31750, 47687, 47806, 76448,
76535, 92453, 92554, 123276, 123470, 146090, 146213]
cm = Crossmap(rna, [], -1)
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(146214)) == '1-u1'
assert cm.tuple2string(cm.g2x(146214)) == '-1'
assert cm.tuple2string(cm.g2x(146213)) == '1'
assert cm.tuple2string(cm.g2x(146089)) == '124+1'
# Fix for r536: disable the -u and +d convention.
# assert cm.tuple2string(cm.g2x(1999)) == '1624+d1'
assert cm.tuple2string(cm.g2x(1999)) == '*1'
def test_x2g_noncoding():
"""
Do some n. to g. conversion checking for the gene on the forward
strand.
"""
rna = [5002, 5125, 27745, 27939, 58661, 58762, 74680, 74767, 103409,
103528, 119465, 119537, 144687, 144810, 148418, 149215]
cm = Crossmap(rna, [], 1)
assert cm.x2g(1, -1) == 5001
assert cm.x2g(1, 0) == 5002
assert cm.x2g(124, 1) == 5126
assert cm.x2g(1624, 1) == 149216
def test_x2g_noncoding_reverse():
"""
Do some n. to g. conversion checking for the gene on the reverse