Passed
Push — master ( 58c8ed...66a482 )
by Marcin
01:59
created

splix_math   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A Allele.__sub__() 0 2 1
A Allele.__init__() 0 3 1
A Allele.__add__() 0 2 1
A Allele.__repr__() 0 2 1
A Allele.delete() 0 2 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
"""
4
5
"""
6
from __future__ import print_function
7
8
import argparse
9
10
11
"""
12
python splix_math.py 
13
[2, 1]
14
[0, 0]
15
[1, 0]
16
cwc15      1 1
17
prp16-302  1 0
18
bsc        -1 -1
19
bsg        0 -1
20
Δcwc15     1 1
21
"""
22
23
import gc
24
25
    
26
class Allele():
27
    def __init__(self, name, mechanism):
28
        self.name = name
29
        self.m = mechanism
30
        #if '\'' in mechanism:
31
        #    self.m = [1,0]
32
        #if '/' in mechanism:
33
        #    self.m = [0,1]
34
35
    def __add__(self, other):
36
        return [self.m[0] + other.m[0], self.m[1] + other.m[1]]  
37
38
    def __sub__(self, other):
39
        return [self.m[0] - other.m[0], self.m[1] - other.m[1]]  
40
41
    def delete(self):
42
        return Allele('Δ' + self.name, [self.m[1], self.m[0]])
43
44
    def __repr__(self):
45
        return ' '.join([self.name.ljust(10), str(self.m[0]), str(self.m[1])])
46
    #def __del__(self, other):
47
    #    return [-self.m[0], self.m[1]]
48
49
50
if __name__ == '__main__':
51
    # \ -> [0,5]
52
    c15 = Allele('cwc15',  [+1,+1])
53
    _302 = Allele('prp16-302',  [+1,0])
54
    bsc = Allele('bsc', [-1, -1])
55
    bsg = Allele('bsg', [0,-1])
56
    dc15 = c15.delete()
57
58
    print(dc15 + _302)
59
    print(c15 + bsc)
60
    print(c15 + bsg)
61
62
    for a in gc.get_objects(): # [c15, _302]:
63
        if isinstance(a, Allele):
64
            print(a)
65