diff --git a/extras/soap-tools/getTranscriptsAndInfo.py b/extras/soap-tools/getTranscriptsAndInfo.py index ce3b1a223c562a50595c9e0aca03a3c08eed6650..ee5a9e72ddee475713f003527cee930d625688cd 100755 --- a/extras/soap-tools/getTranscriptsAndInfo.py +++ b/extras/soap-tools/getTranscriptsAndInfo.py @@ -40,15 +40,18 @@ def main(genomic_reference, gene=None): Locus tag: %s Link method: %s Translation: - Start: %s (c), %s (g) - End: %s (c), %s (g) + Start: %s (c), %s (g), %s (chrom) + End: %s (c), %s (g), %s (chrom) Sortable end: %s CDS: - Start: %s (c), %s (g) - End: %s (c), %s (g)""" % \ + Start: %s (c), %s (g), %s (chrom) + End: %s (c), %s (g), %s (chrom)""" % \ (t.name, t.id, t.product, t.locusTag, t.linkMethod, t.cTransStart, - t.gTransStart, t.cTransEnd, t.gTransEnd, t.sortableTransEnd, - t.cCDSStart, t.gCDSStart, t.cCDSStop, t.gCDSStop) + t.gTransStart, t.chromTransStart if 'chromTransStart' in t else '-', + t.cTransEnd, t.gTransEnd, t.chromTransEnd if 'chromTransEnd' in t else '-', + t.sortableTransEnd, t.cCDSStart, t.gCDSStart, + t.chromCDSStart if 'chromCDSStart' in t else '-', t.cCDSStop, t.gCDSStop, + t.chromCDSStop if 'chromCDSStop' in t else '-') if 'proteinTranscript' in t: print """ Protein: @@ -61,8 +64,10 @@ def main(genomic_reference, gene=None): if 'exons' in t: print ' Exons:' for e in t.exons.ExonInfo: - print ' %s - %s (c), %s - %s (g)' % \ - (e.cStart, e.cStop, e.gStart, e.gStop) + print ' %s - %s (c), %s - %s (g), %s - %s (chrom)' % \ + (e.cStart, e.cStop, e.gStart, e.gStop, + e.chromStart if 'chromStart' in e else '-', + e.chromStop if 'chromStop' in e else '-') if __name__ == '__main__': diff --git a/mutalyzer/GenRecord.py b/mutalyzer/GenRecord.py index 90d50c0f16a67764cc83e49944b9fc8bf04e976d..91ddb1994c9cacd1506391ee476c65dbff00e34b 100644 --- a/mutalyzer/GenRecord.py +++ b/mutalyzer/GenRecord.py @@ -351,6 +351,8 @@ class Record(object) : @return: chromosomal g. position @rtype: integer """ + if not self.chromOffset: + return None if self.orientation == 1 : return self.chromOffset + i - 1 diff --git a/mutalyzer/models.py b/mutalyzer/models.py index d539e91356e6ff2a20046716b58ebad4dbea8fb1..41c3afd82ad45a256e1d6c49b6660d5cef7cf37e 100644 --- a/mutalyzer/models.py +++ b/mutalyzer/models.py @@ -147,8 +147,10 @@ class ExonInfo(ClassModel): cStart = Mandatory.String gStart = Mandatory.Integer + chromStart = Integer cStop = Mandatory.String gStop = Mandatory.Integer + chromStop = Integer #ExonInfo @@ -168,9 +170,11 @@ class TranscriptInfo(ClassModel): """ Used in return type of SOAP method getTranscriptsAndInfo. - @todo: Decide on 'stop' versus 'end'. Web interface uses 'stop' for - both trans and CDS. Ivar asked for 'end'. Internally, we have - trans 'end' and CDS 'stop'. + @todo: Decide on 'stop' versus 'end'. Web interface uses 'stop' for both + trans and CDS. Ivar asked for 'end'. Internally, we have trans 'end' + and CDS 'stop'. + @todo: We should really also provide the chromosome (or its accession + number) next to the chromosomal positions, if available. """ __namespace__ = SOAP_NAMESPACE @@ -180,14 +184,18 @@ class TranscriptInfo(ClassModel): cTransStart = Mandatory.String gTransStart = Mandatory.Integer + chromTransStart = Integer cTransEnd = Mandatory.String gTransEnd = Mandatory.Integer + chromTransEnd = Integer sortableTransEnd = Mandatory.Integer cCDSStart = Mandatory.String gCDSStart = Mandatory.Integer + chromCDSStart = Integer cCDSStop = Mandatory.String gCDSStop = Mandatory.Integer + chromCDSStop = Integer locusTag = Mandatory.String linkMethod = Mandatory.String diff --git a/mutalyzer/parsers/genbank.py b/mutalyzer/parsers/genbank.py index 34568dc2bc1f3ddc94dd55e75665578d4a6c451c..b6d384ff80c33a7b6a979d6cedb51a39cd36b597 100644 --- a/mutalyzer/parsers/genbank.py +++ b/mutalyzer/parsers/genbank.py @@ -501,7 +501,11 @@ class GBparser(): geneDict = {} accInfo = biorecord.annotations['accessions'] - if len(accInfo) >= 3 and accInfo[1] == "REGION:" : + if len(accInfo) >= 3 and accInfo[1] == "REGION:": + # Todo: This information is present in the genbank file if it is a + # UD sliced from a chromosome. We can get the same information + # for NM references from our mapping database and that way + # also provide chromosomal variant descriptions for those. region = accInfo[2] if "complement" in region : record.orientation = -1 diff --git a/mutalyzer/webservice.py b/mutalyzer/webservice.py index 8230647bce26c85ee9c1f377c7a81e75083be706..71c3447b6991e488ca54ed4f866383b231674aea 100644 --- a/mutalyzer/webservice.py +++ b/mutalyzer/webservice.py @@ -787,20 +787,26 @@ class MutalyzerService(DefinitionBase): - product - cTransStart - gTransStart + - chromTransStart - cTransEnd - gTransEnd + - chromTransEnd - sortableTransEnd - cCDSStart - gCDSStart + - chromCDSStart - cCDSStop - gCDSStop + - chromCDSStop - locusTag - linkMethod - exons: Array of ExonInfo objects with fields: - cStart - gStart + - chromStart - cStop - gStop + - chromStop - proteinTranscript: ProteinTranscript object with fields: - name - id @@ -847,8 +853,10 @@ class MutalyzerService(DefinitionBase): exon = ExonInfo() exon.gStart = transcript.CM.getSpliceSite(i) exon.cStart = transcript.CM.g2c(exon.gStart) + exon.chromStart = GenRecordInstance.record.toChromPos(exon.gStart) exon.gStop = transcript.CM.getSpliceSite(i + 1) exon.cStop = transcript.CM.g2c(exon.gStop) + exon.chromStop = GenRecordInstance.record.toChromPos(exon.gStop) t.exons.append(exon) # Beware that CM.info() gives a made-up value for trans_end, @@ -861,6 +869,7 @@ class MutalyzerService(DefinitionBase): t.cTransEnd = str(t.exons[-1].cStop) t.gTransEnd = t.exons[-1].gStop + t.chromTransEnd = GenRecordInstance.record.toChromPos(t.gTransEnd) t.sortableTransEnd = sortable_trans_end # Todo: If we have no CDS info, CM.info() gives trans_end as @@ -873,10 +882,13 @@ class MutalyzerService(DefinitionBase): t.product = transcript.transcriptProduct t.cTransStart = str(trans_start) t.gTransStart = transcript.CM.x2g(trans_start, 0) + t.chromTransStart = GenRecordInstance.record.toChromPos(t.gTransStart) t.cCDSStart = str(cds_start) t.gCDSStart = transcript.CM.x2g(cds_start, 0) + t.chromCDSStart = GenRecordInstance.record.toChromPos(t.gCDSStart) t.cCDSStop = str(cds_stop) t.gCDSStop = transcript.CM.x2g(cds_stop, 0) + t.chromCDSStop = GenRecordInstance.record.toChromPos(t.gCDSStop) t.locusTag = transcript.locusTag t.linkMethod = transcript.linkMethod @@ -948,6 +960,10 @@ class MutalyzerService(DefinitionBase): def sliceChromosome(self, chromAccNo, start, end, orientation) : """ Todo: documentation, error handling, argument checking, tests. + + @arg orientation: Orientation of the slice. 1 for forward, 2 for + reverse complement. + @type orientation: integer """ O = Output(__file__) D = Db.Cache() diff --git a/tests/test_webservice.py b/tests/test_webservice.py index f50ecc3e3597969755d9d69fd77982fdd8006e0a..775e5521569b59305a434a64ee08567ac99cd339 100644 --- a/tests/test_webservice.py +++ b/tests/test_webservice.py @@ -59,8 +59,8 @@ class TestWebservice(): @todo: Start the standalone server and stop it in self.tearDown instead of depending on some running instance at a fixed address. """ - self.client = Client(WSDL_URL, cache=None) - #self.client.options.cache.setduration(seconds=120) + self.client = Client(WSDL_URL) #, cache=None) + self.client.options.cache.setduration(seconds=120) def test_checksyntax_valid(self): """ @@ -400,3 +400,37 @@ class TestWebservice(): assert_equal(r.sourceVersion, '1') assert_equal(r.sourceGi, '256574794') assert_equal(r.molecule, 'g') + + @skip + def test_gettranscriptsandinfo_slice(self): + """ + Running getTranscriptsAndInfo on a chromosomal slice should include + chromosomal positions. + + slice: 48284000 - 48259456 (COL1A1 with 5001 and 2001 borders) + translation start: 48284000 - 5001 + 1 = 48279000 + translation end: 48259456 + 2001 = 48261457 + + Todo: We cannot use UD references in unit tests, unless we implement + a way to create them inside the unit test. + """ + r = self.client.service.getTranscriptsAndInfo('UD_129646580028') + assert_equal(type(r.TranscriptInfo), list) + names = [t.name for t in r.TranscriptInfo] + assert 'COL1A1_v001' in names + for t in r.TranscriptInfo: + if t.name != 'COL1A1_v001': + continue + assert_equal(t.cTransStart, '-126') + assert_equal(t.gTransStart, 5001) + assert_equal(t.chromTransStart, 48279000) + assert_equal(t.cTransEnd, '*1406') + assert_equal(t.gTransEnd, 22544) + assert_equal(t.chromTransEnd, 48261457) + assert_equal(t.sortableTransEnd, 5801) + assert_equal(t.cCDSStart, '1') + assert_equal(t.gCDSStart, 5127) + assert_equal(t.chromCDSStart, 48278874) + assert_equal(t.cCDSStop, '4395') + assert_equal(t.gCDSStop, 21138) + assert_equal(t.chromCDSStop, 48262863)