annotate resfinder/cge/phenotype2genotype/dbhit.py @ 0:a16d245332d6 draft default tip

Uploaded
author dcouvin
date Wed, 08 Dec 2021 01:46:07 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
1 #!/usr/bin/env python3
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
2
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
3
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
4 class DBHit(object):
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
5 """ A DBHit describes an alignment of a feature to a reference/template.
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
6 The db variable should be used to describe which database the alignment
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
7 in question was done against. For example 'resfinder'
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
8
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
9 The match_category variable stores one of the integers:
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
10 1: Match < 100% identity AND match_length < ref_length
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
11 2: Match < 100% identity AND match_length == ref_length
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
12 3: Match == 100% identity AND match_length == ref_length
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
13 """
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
14 def __init__(self, name, identity, match_length, ref_length, start_ref,
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
15 end_ref, acc, depth=None, db=None):
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
16 self.name = name
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
17 self.identity = float(identity)
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
18 if(match_length == "NA"):
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
19 self.match_length = None
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
20 else:
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
21 self.match_length = int(match_length)
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
22 self.ref_length = int(ref_length)
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
23 self.start_ref = int(start_ref)
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
24 self.end_ref = int(end_ref)
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
25 self.acc = acc
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
26 self.depth = depth
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
27 self.db = db
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
28
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
29 if(self.match_length is not None
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
30 and self.ref_length != self.match_length):
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
31 self.match_category = 1
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
32 elif(self.identity < 100.0):
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
33 self.match_category = 2
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
34 else:
a16d245332d6 Uploaded
dcouvin
parents:
diff changeset
35 self.match_category = 3