Changeset 291
- Timestamp:
- 02/01/08 00:08:14 (10 months ago)
- Files:
-
- trunk/cartwheel-server/data-model/website/motifs.sql (modified) (1 diff)
- trunk/cartwheel-server/lib/cartwheel/website/PWMMotif.py (modified) (3 diffs)
- trunk/cartwheel-server/lib/cucumber/_utils.py (modified) (1 diff)
- trunk/cartwheel-server/website/canal/motif/pages_pwm.ptl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cartwheel-server/data-model/website/motifs.sql
r286 r291 38 38 class_id INTEGER REFERENCES classes DEFAULT :class_id, 39 39 source_motifs TEXT DEFAULT '', 40 palindromic BOOLEAN DEFAULT 'f', 40 41 threshold FLOAT 41 42 ) INHERITS (named_motifs); trunk/cartwheel-server/lib/cartwheel/website/PWMMotif.py
r286 r291 2 2 A PWM motif created from a list of sites. 3 3 """ 4 import fasta 4 5 from cartwheel.website.NamedMotif import NamedMotif 5 6 6 7 class PWMMotif(NamedMotif): 7 8 table = 'pwm_motifs' 8 mymembers = ('source_motifs', 'threshold' )9 mymembers = ('source_motifs', 'threshold', 'palindromic') 9 10 10 11 def make_pwm(self): … … 12 13 13 14 sites = self.source_motifs.split("\n") 15 if self.palindromic: 16 rc_sites = [ fasta.rc(site) for site in sites ] 17 sites.extend(rc_sites) 18 14 19 pwm = motility.make_pwm(sites) 15 20 return pwm … … 21 26 import motility 22 27 23 sites = self.source_motifs.split("\n") 24 pwm = motility.make_pwm(sites) 28 pwm = self.make_pwm() 25 29 26 30 return pwm.find(sequence.seq[start:stop], trunk/cartwheel-server/lib/cucumber/_utils.py
r285 r291 151 151 elif type(value) == DateTime.DateTimeType: 152 152 return "'%s'" % (str(value),) 153 elif type(value) == bool: 154 if value: 155 return "'t'" 156 else: 157 return "'f'" 153 158 elif value is None: 154 159 return 'NULL' trunk/cartwheel-server/website/canal/motif/pages_pwm.ptl
r288 r291 48 48 errors.extend(utils.validate_pwm_input(sequences, threshold)) 49 49 50 if 'palindromic' in request.form: 51 if request.form['palindromic'] == 'yes': 52 motif.palindromic = True 53 else: 54 motif.palindromic = False 55 50 56 if 'notes' in request.form: 51 57 notes = request.form['notes'] … … 65 71 66 72 # fill 73 palindromic = 'no' 74 if motif.palindromic: 75 palindromic = 'yes' 76 67 77 values = dict(motif_id=motif.id, 68 78 name=motif.name, 69 79 sequences=motif.source_motifs, 70 80 threshold=round(motif.threshold, 3), 81 palindromic=palindromic, 71 82 notes=motif.notes) 72 83 73 pwm = moti lity.make_pwm(sequences)84 pwm = motif.make_pwm() 74 85 75 86 formhtml = """\ … … 85 96 <p> 86 97 Threshold: <input type='text' name='threshold' size='7'> 98 <p> 99 Are binding sites palindromic? 100 <select name='palindromic'> 101 <option value='no'> No 102 <option value='yes'> Yes 103 </select> 87 104 <p> 88 105 Notes:<br> … … 98 115 """ % (motif.name,) 99 116 100 formhtml = htmlfill.render(formhtml, values)101 102 117 return wrap(htmlfill.render(formhtml, values), 103 118 display_pwm_information(pwm, sequences, threshold), … … 183 198 ### 184 199 185 template display_pwm_from_sites(request, name, sequences, notes):186 header("Motif '%s' created" % (name,))187 188 "<h2>Matrix motif '%s' created.</h2>" % (name,)189 190 pwm = motility.make_pwm(sequences)191 site_scores = [ (pwm.calc_score(s),s) for s in sequences ]192 site_scores.sort()193 site_scores.reverse()194 195 lowest_score = site_scores[-1][0]196 197 ###198 199 display_pwm_information(pwm, sequences, lowest_score)200 201 ### create202 203 manager = cartwheel.website.get_object_manager()204 205 folder_id = request.session.get_current_folder().id206 207 m = manager.create(PWMMotif, name=name, source_motifs="\n".join(sequences),208 motif_type='PWM',209 threshold=lowest_score,210 notes=notes,211 folder_id=folder_id)212 213 manager.commit()214 215 """216 <p>217 <a href='./edit?motif_id=%d'>Edit motif information and threshold</a>218 <p>219 <a href='./'>Return to motif list</a>220 """ % (m.id,)221 222 footer()223 224 200 def build_pwm_from_list(request): 225 201 if not request.form: … … 250 226 <textarea name='sequences' rows='5' cols='30'></textarea> 251 227 <p> 228 Are binding sites palindromic? 229 <select name='palindromic'> 230 <option value='no'> No 231 <option value='yes'> Yes 232 </select> 233 <p> 252 234 Notes:<br> 253 235 <blockquote> … … 283 265 errors.extend(utils.validate_pwm_input(sequences)) 284 266 267 268 if request.form['palindromic'] == 'yes': 269 palindromic = True 270 else: 271 palindromic = False 272 285 273 if errors: 286 274 return error("ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors,))) … … 288 276 ### ok, validation good so far. build the PWM & display... 289 277 290 return display_pwm_from_sites(request, name, sequences, notes) 291 292 template display_pwm_from_sites(request, name, sequences, notes): 293 header("Motif '%s' created" % (name,)) 294 295 "<h2>Matrix motif '%s' created.</h2>" % (name,) 296 297 pwm = motility.make_pwm(sequences) 278 return display_pwm_from_sites(request, name, sequences, notes, 279 palindromic) 280 281 template display_pwm_from_sites(request, name, sequences, notes, 282 palindromic): 283 ### create 284 285 manager = cartwheel.website.get_object_manager() 286 287 folder_id = request.session.get_current_folder().id 288 289 m = manager.create(PWMMotif, name=name, source_motifs="\n".join(sequences), 290 motif_type='PWM', 291 threshold=0, 292 notes=notes, 293 palindromic=palindromic, 294 folder_id=folder_id) 295 296 pwm = m.make_pwm() 298 297 site_scores = [ (pwm.calc_score(s),s) for s in sequences ] 299 298 site_scores.sort() … … 301 300 302 301 lowest_score = site_scores[-1][0] 303 304 ### 305 302 m.threshold = lowest_score 303 304 manager.commit() 305 306 ### 307 308 header("Motif '%s' created" % (name,)) 309 310 "<h2>Matrix motif '%s' created.</h2>" % (name,) 311 312 if palindromic: 313 """(This motif is palindromic: all sites are added forward & reverse complement)<p>""" 314 306 315 display_pwm_information(pwm, sequences, lowest_score) 307 308 ### create309 310 manager = cartwheel.website.get_object_manager()311 312 folder_id = request.session.get_current_folder().id313 314 m = manager.create(PWMMotif, name=name, source_motifs="\n".join(sequences),315 motif_type='PWM',316 threshold=lowest_score,317 notes=notes,318 folder_id=folder_id)319 320 manager.commit()321 316 322 317 """
