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

Source Code for Module Bio.Search

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