Package Bio :: Module Search
[hide private]
[frames] | no frames]

Source Code for Module Bio.Search

  1  # BLASTN 2.0a19MP-WashU [05-Feb-1998] [Build decunix3.2 01:53:29 05-Feb-1998] 
  2  # BLASTP 2.0.4 [Feb-24-1998] 
3 -class Algorithm:
4 - def __init__(self, name, version, description = ""):
5 self.name = name # 'blastx', 'blastn', etc. 6 self.version = version # '2.1.2' or '2.0a19MP-WashU' 7 self.description = description # '[05-Feb-1998] [Build dec ...1998]'
8 9 # Query= YAL001C YAL001C, Chr I from 147596 to 147665, and 147756 to 151168, 10 # reverse complement 11 # (3483 letters)
12 -class Query:
13 - def __init__(self, name, accession, description, length):
14 self.name = name # 'YAL001C' 15 self.accession = accession # or None if missing 16 self.description = description # 'YAL001C, Chr I from 147596 to ... ' 17 self.length = length # 3483
18 19 # Database: ArabidopsisN 20 # 66,211 sequences; 69,074,155 total letters.
21 -class Database:
22 - def __init__(self, name, letters, entries):
23 self.name = name # ArabidopsisN 24 self.letters = letters # 69074155 25 self.entries = entries # 66211
26
27 -class TableInfo:
28 - def __init__(self, full_description, info):
29 self.__dict__.update(info) 30 self.full_description = full_description
31 32
33 -class Search:
34 - def __init__(self, algorithm, query, database, table, hits, 35 parameters, statistics):
36 self.algorithm = algorithm 37 self.query = query 38 self.database = database 39 self.table = table 40 self.hits = hits 41 self.parameters = parameters 42 self.statistics = statistics
43
44 -class Hit:
45 - def __init__(self, name, description, accession, length, 46 algorithm, hsps = None):
47 self.name = name 48 self.description = description 49 self.accession = accession 50 self.length = length 51 self.algorithm = algorithm 52 if hsps is None: 53 hsps = [] 54 self.hsps = hsps
55
56 - def __len__(self):
57 return self.length
58 59 60 61 # >GB_PL:ATF18F4 AL021637 Arabidopsis thaliana DNA chromosome 4, BAC clone 62 # F18F4 (ESSAII project). 2/98 63 # Length = 93,646 64 # 65 # Minus Strand HSPs: 66 # 67 # Score = 226 (33.9 bits), Expect = 0.80, P = 0.55 68 # Identities = 98/142 (69%), Positives = 98/142 (69%), Strand = Minus / Plus 69 # [...lines deleted...] 70 # Query: 2486 ATATCAAGCAATTTGATAAGATCTAG 2461 71 # A AT A C ATT GA AAGATC AG 72 # Sbjct: 85387 AGATTTACCTATT-GAGAAGATCAAG 85411 73 74 # computed from the strings
75 -class _SeqLength:
76 - def __init__(self, length, identical, positives, gaps):
77 self.length = length 78 self.identical = identical 79 self.positives = positives 80 self.gaps = gaps
81 - def __len__(self):
82 return self.length
83 - def __getattr__(self, name):
84 if name == "frac_identical": 85 return float(self.identical) / self.length 86 elif name == "frac_positives": 87 return float(self.positives) / self.length 88 raise AttributeError(name)
89 90
91 -class HomologySeq(_SeqLength):
92 - def __init__(self, seq, identical, positives, gaps):
93 _SeqLength.__init__(self, len(seq), identical, positives, gaps) 94 self.seq = seq
95
96 -class HSPSeq(_SeqLength):
97 - def __init__(self, name, seq, location, identical, positives, gaps):
98 _SeqLength.__init__(self, len(seq), identical, positives, gaps) 99 self.name = name 100 self.seq = seq 101 self.location = location
102 103
104 -class HSP(_SeqLength):
105 - def __init__(self, 106 query_seq, # ATATCAAGCAATTTGATAAGATCTAG 107 homology_seq, # A AT A C ATT GA AAGATC AG 108 subject_seq, # AGATTTACCTATT-GAGAAGATCAAG 109 110 query_location, # (2486, 2461, negative strand) 111 subject_location, # (85387, 85411) 112 113 query_name, # Query (or None) 114 subject_name, # Sbjct (or None) 115 116 algorithm, # an Algorithm 117 info, # contains Key/value pairs 118 homology_gaps = None, # Is this needed? 119 ):
120 assert len(query_seq) == len(homology_seq) == len(subject_seq), \ 121 (query_seq, homology_seq, subject_seq) 122 self.algorithm = algorithm 123 124 query_gaps = query_seq.count("-") 125 subject_gaps = subject_seq.count("-") 126 if homology_gaps is None: 127 homology_gaps = query_gaps + subject_gaps 128 self.info = info 129 130 identical = info["identical"] 131 # bioperl calls this 'conserved' 132 positives = info.get("positives", identical) 133 134 _SeqLength.__init__(self, len(query_seq), identical, 135 positives, homology_gaps) 136 137 self.query = HSPSeq(name = query_name, 138 seq = query_seq, 139 location = query_location, 140 identical = identical, 141 positives = positives, 142 gaps = query_gaps) 143 144 self.subject = HSPSeq(name = subject_name, 145 seq = subject_seq, 146 location = subject_location, 147 identical = identical, 148 positives = positives, 149 gaps = subject_gaps) 150 self.homology = HomologySeq(seq = homology_seq, 151 identical = identical, 152 positives = positives, 153 gaps = homology_gaps)
154