Changeset 291

Show
Ignore:
Timestamp:
02/01/08 00:08:14 (10 months ago)
Author:
t
Message:

added 'palindromic' flag.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cartwheel-server/data-model/website/motifs.sql

    r286 r291  
    3838        class_id INTEGER REFERENCES classes DEFAULT :class_id, 
    3939        source_motifs TEXT DEFAULT '', 
     40        palindromic BOOLEAN DEFAULT 'f', 
    4041        threshold FLOAT 
    4142) INHERITS (named_motifs); 
  • trunk/cartwheel-server/lib/cartwheel/website/PWMMotif.py

    r286 r291  
    22A PWM motif created from a list of sites. 
    33""" 
     4import fasta 
    45from cartwheel.website.NamedMotif import NamedMotif 
    56 
    67class PWMMotif(NamedMotif): 
    78    table = 'pwm_motifs' 
    8     mymembers = ('source_motifs', 'threshold'
     9    mymembers = ('source_motifs', 'threshold', 'palindromic'
    910 
    1011    def make_pwm(self): 
     
    1213 
    1314        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         
    1419        pwm = motility.make_pwm(sites) 
    1520        return pwm 
     
    2126        import motility 
    2227 
    23         sites = self.source_motifs.split("\n") 
    24         pwm = motility.make_pwm(sites) 
     28        pwm = self.make_pwm() 
    2529 
    2630        return pwm.find(sequence.seq[start:stop], 
  • trunk/cartwheel-server/lib/cucumber/_utils.py

    r285 r291  
    151151    elif type(value) == DateTime.DateTimeType: 
    152152        return "'%s'" % (str(value),) 
     153    elif type(value) == bool: 
     154        if value: 
     155            return "'t'" 
     156        else: 
     157            return "'f'" 
    153158    elif value is None: 
    154159        return 'NULL' 
  • trunk/cartwheel-server/website/canal/motif/pages_pwm.ptl

    r288 r291  
    4848            errors.extend(utils.validate_pwm_input(sequences, threshold)) 
    4949 
     50    if 'palindromic' in request.form: 
     51        if request.form['palindromic'] == 'yes': 
     52            motif.palindromic = True 
     53        else: 
     54            motif.palindromic = False 
     55 
    5056    if 'notes' in request.form: 
    5157        notes = request.form['notes'] 
     
    6571     
    6672    # fill 
     73    palindromic = 'no' 
     74    if motif.palindromic: 
     75        palindromic = 'yes' 
     76         
    6777    values = dict(motif_id=motif.id, 
    6878                  name=motif.name, 
    6979                  sequences=motif.source_motifs, 
    7080                  threshold=round(motif.threshold, 3), 
     81                  palindromic=palindromic, 
    7182                  notes=motif.notes) 
    7283 
    73     pwm = motility.make_pwm(sequences
     84    pwm = motif.make_pwm(
    7485 
    7586    formhtml = """\ 
     
    8596<p> 
    8697Threshold: <input type='text' name='threshold' size='7'> 
     98<p> 
     99Are binding sites palindromic? 
     100 <select name='palindromic'> 
     101   <option value='no'> No 
     102   <option value='yes'> Yes 
     103 </select> 
    87104<p> 
    88105Notes:<br> 
     
    98115""" % (motif.name,) 
    99116 
    100     formhtml = htmlfill.render(formhtml, values) 
    101      
    102117    return wrap(htmlfill.render(formhtml, values), 
    103118                display_pwm_information(pwm, sequences, threshold), 
     
    183198    ### 
    184199 
    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     ### create 
    202  
    203     manager = cartwheel.website.get_object_manager() 
    204  
    205     folder_id = request.session.get_current_folder().id 
    206  
    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  
    224200def build_pwm_from_list(request): 
    225201    if not request.form: 
     
    250226<textarea name='sequences' rows='5' cols='30'></textarea> 
    251227<p> 
     228Are binding sites palindromic? 
     229 <select name='palindromic'> 
     230   <option value='no'> No 
     231   <option value='yes'> Yes 
     232 </select> 
     233<p> 
    252234Notes:<br> 
    253235<blockquote> 
     
    283265        errors.extend(utils.validate_pwm_input(sequences)) 
    284266 
     267     
     268    if request.form['palindromic'] == 'yes': 
     269        palindromic = True 
     270    else: 
     271        palindromic = False 
     272 
    285273    if errors: 
    286274        return error("ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors,))) 
     
    288276    ### ok, validation good so far.  build the PWM & display... 
    289277     
    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 
     281template 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() 
    298297    site_scores = [ (pwm.calc_score(s),s) for s in sequences ] 
    299298    site_scores.sort() 
     
    301300 
    302301    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     
    306315    display_pwm_information(pwm, sequences, lowest_score) 
    307  
    308     ### create 
    309  
    310     manager = cartwheel.website.get_object_manager() 
    311  
    312     folder_id = request.session.get_current_folder().id 
    313  
    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() 
    321316 
    322317    """