forked from molgenis/VaSeBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_id_object.py
81 lines (64 loc) · 2.03 KB
/
read_id_object.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""Pseudo-pysam.AlignedSegment object used as a placeholder when reading varcon files."""
class ReadIdObject:
"""The ReadIdObject is used to save the read identifiers.
This class is used when a VariantContextFile is read. DonorBamRead can't
be used as most data is missing.
Attributes
----------
query_name : str
Identifier of the read
pair_number : str
Pair number of the read
"""
def __init__(self, readid):
"""Save the read id and set the pairnumber to a default empty value."""
self.query_name = readid
self.pair_number = ""
def get_bam_read_id(self):
"""Return the identifier of the read.
Returns
-------
self.read_id : str
Identifier of the read
"""
return self.query_name
def set_bam_read_id(self, readid):
"""Set the identifier of the read. Overwrite any already existing value.
Parameters
----------
readid : str
The read identifier to set
"""
self.query_name = readid
def get_bam_read_pair_number(self):
"""Return the read pair number of the read.
Returns
-------
self.pair_number : str
The read pair number
"""
return self.pair_number
def set_bam_read_pair_number(self, pairnum):
"""Set the read pair number of the read. Overwrite any already existing value.
Parameters
----------
pairnum : str
The pair number to set
"""
self.pair_number = pairnum
def is_read1(self):
"""Return whether the read is the forward/R1 read.
Returns
-------
bool
True if read pair number is 1., False if not
"""
return self.pair_number == "1"
def is_read2(self):
"""Return whether the read is the reverse/R2 read.
Returns
-------
bool
True if read pair number is 2, False if not
"""
return self.pair_number == "2"