Changeset 279
- Timestamp:
- 01/21/08 23:59:50 (10 months ago)
- Files:
-
- trunk/cartwheel-server/lib/pygr_draw/nlmsa.py (modified) (1 diff)
- trunk/cartwheel-server/tests/functional-tests/test-with-user/test-web/test-folder-motifs.py (modified) (2 diffs)
- trunk/cartwheel-server/website/canal/motif/__init__.py (modified) (3 diffs)
- trunk/cartwheel-server/website/canal/motif/analyze.ptl (modified) (5 diffs)
- trunk/cartwheel-server/website/canal/motif/pages.ptl (modified) (3 diffs)
- trunk/cartwheel-server/website/canal/motif/utils.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cartwheel-server/lib/pygr_draw/nlmsa.py
r272 r279 7 7 with the sequence(s). 8 8 """ 9 if not annotations: 10 raise Exception("you must specify some annotations") 11 9 12 annotations_map = cnestedlist.NLMSA('test', mode='memory', 10 13 use_virtual_lpo=True) trunk/cartwheel-server/tests/functional-tests/test-with-user/test-web/test-folder-motifs.py
r278 r279 195 195 find("Matrix motif 'test_pwm_gata' created.") 196 196 find("current threshold: 10.58") 197 find( "prob/base with this score: 0.000732422")197 find('0.000732422') # p(motif)/base 198 198 199 199 follow("Return to motif list") … … 222 222 223 223 find('current threshold: 6.75') 224 find(' prob/base with this score: 0.03125')224 find('0.03125') # p(motif)/base 225 225 226 226 follow("Return to motif list") trunk/cartwheel-server/website/canal/motif/__init__.py
r278 r279 115 115 Mismatches to allow by default: <input type='text' name='mismatches' size='4'> 116 116 <p> 117 <input type='submit' value='save & return to motif list' name='return'> 117 118 <input type='submit' value='save changes'> 118 <input type='submit' value='save & return to motif list' name='return'>119 119 <input type='reset' value='reset form'> 120 120 </form> … … 170 170 name=motif.name, 171 171 sequences=motif.source_motifs, 172 default_threshold= motif.default_threshold)172 default_threshold=round(motif.default_threshold, 2)) 173 173 174 174 pwm = motility.make_pwm(sequences) … … 185 185 <textarea name='sequences' rows='5' cols='30'></textarea> 186 186 <p> 187 Threshold: <input type='text' name='default_threshold' size=' 5'>187 Threshold: <input type='text' name='default_threshold' size='7'> 188 188 189 189 <p> 190 <input type='submit' value='save changes'>191 190 <input type='submit' value='save & return to motif list' name='return'> 191 <input type='submit' value='save & update information'> 192 192 <input type='reset' value='reset form'> 193 193 </form> trunk/cartwheel-server/website/canal/motif/analyze.ptl
r276 r279 1 1 """ 2 2 Web handler for dealing with sequence analysis by motifs. 3 4 CTB to test: 5 - empty annotations 3 6 """ 4 7 … … 26 29 Do the motif search & use pygr_draw to actually draw a picture. 27 30 """ 28 31 29 32 sequencedb = dict(sequence=pygr.sequence.Sequence(dna_seq.seq,'sequence')) 30 33 colors = picture_class.colors … … 46 49 d[name] = Annotation(name, 'sequence', start, stop, 47 50 color=color) 51 52 if not d: 53 continue 48 54 49 55 map = pygr_draw.create_annotation_map(d, sequencedb) … … 94 100 <h4>Motif matches graphed against sequence:</h4> 95 101 <a href='draw_pdf?start=%d&stop=%d'>(download as PDF)</a><br> 96 <img src='draw_png?start=%d&stop=%d' >102 <img src='draw_png?start=%d&stop=%d' width='100%%'> 97 103 <p> 98 104 """ % (start, stop, start, stop) … … 137 143 138 144 def draw_png(self, request): 139 form = request.form140 seq_start = int(form.get('start', 0))141 seq_start = max(seq_start, 0)142 143 seq_stop = int(form.get('stop', len(self.seq.seq)))144 seq_stop = min(len(self.seq.seq), seq_stop)145 146 (folder, motifs) = get_folder_motifs(self.manager, request)147 148 image = draw_motifs_on_sequence(self.seq, motifs,149 pygr_draw.BitmapSequencePicture,150 seq_start, seq_stop)151 152 request.response.set_content_type('image/png')153 return image145 form = request.form 146 seq_start = int(form.get('start', 0)) 147 seq_start = max(seq_start, 0) 148 149 seq_stop = int(form.get('stop', len(self.seq.seq))) 150 seq_stop = min(len(self.seq.seq), seq_stop) 151 152 (folder, motifs) = get_folder_motifs(self.manager, request) 153 154 image = draw_motifs_on_sequence(self.seq, motifs, 155 pygr_draw.BitmapSequencePicture, 156 seq_start, seq_stop) 157 158 request.response.set_content_type('image/png') 159 return image 154 160 155 161 def draw_pdf(self, request): trunk/cartwheel-server/website/canal/motif/pages.ptl
r278 r279 101 101 Name: <input type='text' name='name'> <p> 102 102 IUPAC sequence to match: <input type='text' name='iupac'><p> 103 Mismatches to allow by default: <input type='text'103 Mismatches to allow: <input type='text' 104 104 name='mismatches' size='4' value='0'><p> 105 105 <input type='submit' value='add IUPAC motif'> 106 106 </form> 107 <p> 108 IUPAC codes: 109 <blockquote><pre> 110 A A Adenine 111 C C Cytosine 112 G G Guanine 113 T T Thymine 114 U U Uracil 115 M A or C 116 R A or G 117 W A or T 118 S C or G 119 Y C or T 120 K G or T 121 V A or C or G 122 H A or C or T 123 D A or G or T 124 B C or G or T 125 N G or A or T or C 126 </pre></blockquote> 107 127 """ 108 128 … … 278 298 "<table border='1'>" + "\n".join(x) + "</table>" 279 299 300 consensus = motility.make_iupac_motif(sequences) 301 """ 302 <p> 303 Consensus motif for this matrix: %s 304 <p> 305 """ % (consensus,) 306 280 307 ### 281 308 … … 308 335 """ 309 336 <p> 310 current threshold: %g; 311 prob/base with this score: %g 312 """ % (threshold, pwm.weight_sites_over(threshold)) 313 314 ### 315 337 Maximum threshold: %.2g 338 """ % (pwm.max_score(),) 339 340 if len(pwm) < 10: 341 weight = pwm.weight_sites_over(threshold) 342 343 """ 344 <p> 345 current threshold: %g.<p> 346 per-base probability of finding a motif at random using this threshold: %g 347 (expect %d motifs per kilobase of random sequence) 348 """ % (threshold, weight, int(2*weight*1000 + 1)) 349 350 ### 351 trunk/cartwheel-server/website/canal/motif/utils.py
r277 r279 51 51 errors.append('Maximum threshold for this matrix motif is %g (which is less than %g)' % (pwm.max_score(), threshold)) 52 52 53 p_val = pwm.weight_sites_over(threshold) 54 if p_val > 0.1: # CTB hard coded? 55 errors.append("With a threshold of %g, this matrix motif has a greater than 10%% chance of being found at *every* DNA position; raise your threshold!" % (threshold)) 53 if len(pwm) < 10: 54 p_val = pwm.weight_sites_over(threshold) 55 if p_val > 0.1: # CTB hard coded? 56 errors.append("With a threshold of %g, this matrix motif has a greater than 10%% chance of being found at *every* DNA position!") 56 57 57 58 ##
