From 753bf60059a6cea43275c1865288310f06759f8c Mon Sep 17 00:00:00 2001 From: "Jeroen F.J. Laros" <jlaros@fixedpoint.nl> Date: Sun, 19 Apr 2015 14:32:02 +0200 Subject: [PATCH] Updated documentation. --- mutalyzer/describe.py | 27 +++++++------ mutalyzer/variant.py | 92 +++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 68 deletions(-) diff --git a/mutalyzer/describe.py b/mutalyzer/describe.py index c4f1da77..f17114ef 100644 --- a/mutalyzer/describe.py +++ b/mutalyzer/describe.py @@ -31,6 +31,15 @@ def printpos(s, start, end, fill=0): def var_to_rawvar(s1, s2, var, seq_list=[], container=DNAVar, weight_position=1): """ + Convert a variant from the extractor module to one of the RawVar + subclasses. + + :arg unicode s1: Reference sequence. + :arg unicode s2: Sample sequence. + :arg str var: Variant from the extractor module. + :arg str seq_list: Container for an inserted sequence. + :arg str container: Destination container. + :arg str weight_position: Weight of a position. """ # Unknown. if s1 == '?' or s2 == '?': @@ -131,13 +140,10 @@ def describe_dna(s1, s2): """ Give an allele description of the change from {s1} to {s2}. - :arg s1: Sequence 1. - :type s1: unicode - :arg s2: Sequence 2. - :type s2: unicode + :arg unicode s1: Sequence 1. + :arg unicode s2: Sequence 2. - :returns: A list of RawVar objects, representing the allele. - :rtype: list(RawVar) + :returns list(RawVar): A list of RawVar objects, representing the allele. """ description = Allele() in_transposition = 0 @@ -190,13 +196,10 @@ def describe_protein(s1, s2): """ Give an allele description of the change from {s1} to {s2}. - :arg s1: Sequence 1. - :type s1: unicode - :arg s2: Sequence 2. - :type s2: unicode + :arg unicode s1: Sequence 1. + :arg unicode s2: Sequence 2. - :returns: A list of RawVar objects, representing the allele. - :rtype: list(RawVar) + :returns list(RawVar): A list of RawVar objects, representing the allele. """ description = Allele() diff --git a/mutalyzer/variant.py b/mutalyzer/variant.py index fc3818d3..2ea2d393 100644 --- a/mutalyzer/variant.py +++ b/mutalyzer/variant.py @@ -1,4 +1,5 @@ """ +Models for the description extractor. """ from __future__ import unicode_literals @@ -71,14 +72,12 @@ class ISeq(object): def __init__(self, sequence='', start=0, end=0, reverse=False, weight_position=1): """ - :arg sequence: Literal inserted sequence. - :type sequence: unicode - :arg start: Start position for a transposed sequence. - :type start: int - :arg end: End position for a transposed sequence. - :type end: int - :arg reverse: Inverted transposed sequence. - :type reverse: bool + Initialise the class with the appropriate values. + + :arg unicode sequence: Literal inserted sequence. + :arg int start: Start position for a transposed sequence. + :arg int end: End position for a transposed sequence. + :arg bool reverse: Inverted transposed sequence. """ self.sequence = sequence self.start = start @@ -130,30 +129,18 @@ class DNAVar(object): """ Initialise the class with the appropriate values. - :arg start: Start position. - :type start: int - :arg start_offset: - :type start_offset: int - :arg end: End position. - :type end: int - :arg end_offset: - :type end_offset: int - :arg sample_start: Start position. - :type sample_start: int - :arg sample_start_offset: - :type sample_start_offset: int - :arg sample_end: End position. - :type sample_end: int - :arg sample_end_offset: - :type sample_end_offset: int - :arg type: Variant type. - :type type: unicode - :arg deleted: Deleted part of the reference sequence. - :type deleted: unicode - :arg inserted: Inserted part. - :type inserted: object - :arg shift: Amount of freedom. - :type shift: int + :arg int start: Start position. + :arg int start_offset: + :arg int end: End position. + :arg int end_offset: + :arg int sample_start: Start position. + :arg int sample_start_offset: + :arg int sample_end: End position. + :arg int sample_end_offset: + :arg unicode type: Variant type. + :arg unicode deleted: Deleted part of the reference sequence. + :arg ISeqList inserted: Inserted part. + :arg int shift: Amount of freedom. """ # TODO: Will this container be used for all variants, or only genomic? # start_offset and end_offset may be never used. @@ -176,8 +163,8 @@ class DNAVar(object): """ Give the HGVS description of the raw variant stored in this class. - :returns: The HGVS description of the raw variant stored in this class. - :rtype: unicode + :returns unicode: The HGVS description of the raw variant stored in + this class. """ if self.type == 'unknown': return '?' @@ -215,31 +202,24 @@ class DNAVar(object): class ProteinVar(object): """ Container for a protein variant. + """ + #NOTE: This is experimental code. It is not used at the moment. def __init__(self, start=0, end=0, sample_start=0, sample_end=0, type='none', deleted=ISeqList([ISeq()]), inserted=ISeqList([ISeq()]), shift=0, term=0): """ Initialise the class with the appropriate values. - :arg start: Start position. - :type start: int - :arg end: End position. - :type end: int - :arg sample_start: Start position. - :type sample_start: int - :arg sample_end: End position. - :type sample_end: int - :arg type: Variant type. - :type type: unicode - :arg deleted: Deleted part of the reference sequence. - :type deleted: unicode - :arg inserted: Inserted part. - :type inserted: object - :arg shift: Amount of freedom. - :type shift: int - :arg term: - :type term: + :arg int start: Start position. + :arg int end: End position. + :arg int sample_start: Start position. + :arg int sample_end: End position. + :arg unicode type: Variant type. + :arg unicode deleted: Deleted part of the reference sequence. + :arg ISeqList inserted: Inserted part. + :arg int shift: Amount of freedom. + :arg int term: Number of positions until stop codon. """ self.start = start self.end = end @@ -257,10 +237,10 @@ class ProteinVar(object): Give the HGVS description of the raw variant stored in this class. Note that this function relies on the absence of values to make the - correct description. Also see the comment in the class definition. + correct description. The method used in the DNAVar is better. - :returns: The HGVS description of the raw variant stored in this class. - :rtype: unicode + :returns unicode: The HGVS description of the raw variant stored in + this class. """ if self.type == 'unknown': return '?' @@ -278,7 +258,7 @@ class ProteinVar(object): description += '{}'.format(self.start) if self.end: description += '_{}{}'.format(seq3(self.end_aa), self.end) - if self.type not in ['subst', 'stop', 'ext', 'fs']: # fs is not a type + if self.type not in ('subst', 'stop', 'ext', 'fs'): # fs is not a type description += self.type if self.inserted: description += '{}'.format(seq3(self.inserted)) -- GitLab