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

Source Code for Module Bio.Search

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