Download this file

55 lines (38 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
import pandas as pd
import numpy as np
import singlecellmultiomics.pyutils as pyutils
class Statistic(object):
"""
Statistic object, initialised with arguments
Parameters
----------
args : argparse object
"""
def __init__(self, args):
self.args = args
def processRead(self, R1,R2=None):
"""
Update the statistic with information from READ
Parameters
----------
read : PySAM Aligned segment
Returns
----------
None
"""
pass
def __repr__(self):
return 'dummy'
class StatisticHistogram(Statistic):
def __init__(self, args):
Statistic.__init__(self, args)
self.histogram = collections.Counter()
def __repr__(self):
return f'Mean {pyutils.meanOfCounter(self.histogram)}, SD:{pyutils.varianceOfCounter(self.histogram)}'
def __iter__(self):
return iter(self.histogram.most_common())
def to_csv(self, path):
pd.DataFrame({__class__.__name__: self.histogram}).to_csv(path)