Changeset 279

Show
Ignore:
Timestamp:
01/21/08 23:59:50 (10 months ago)
Author:
t
Message:

a number of minor fixes to the motif searching stuff, courtesy of erich.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cartwheel-server/lib/pygr_draw/nlmsa.py

    r272 r279  
    77    with the sequence(s). 
    88    """ 
     9    if not annotations: 
     10        raise Exception("you must specify some annotations") 
     11     
    912    annotations_map = cnestedlist.NLMSA('test', mode='memory', 
    1013                                        use_virtual_lpo=True) 
  • trunk/cartwheel-server/tests/functional-tests/test-with-user/test-web/test-folder-motifs.py

    r278 r279  
    195195    find("Matrix motif 'test_pwm_gata' created.") 
    196196    find("current threshold: 10.58") 
    197     find("prob/base with this score: 0.000732422") 
     197    find('0.000732422')                 # p(motif)/base 
    198198 
    199199    follow("Return to motif list") 
     
    222222     
    223223    find('current threshold: 6.75') 
    224     find('prob/base with this score: 0.03125') 
     224    find('0.03125')                     # p(motif)/base 
    225225     
    226226    follow("Return to motif list") 
  • trunk/cartwheel-server/website/canal/motif/__init__.py

    r278 r279  
    115115Mismatches to allow by default: <input type='text' name='mismatches' size='4'> 
    116116<p> 
     117<input type='submit' value='save & return to motif list' name='return'> 
    117118<input type='submit' value='save changes'> 
    118 <input type='submit' value='save & return to motif list' name='return'> 
    119119<input type='reset' value='reset form'> 
    120120</form> 
     
    170170                  name=motif.name, 
    171171                  sequences=motif.source_motifs, 
    172                   default_threshold=motif.default_threshold
     172                  default_threshold=round(motif.default_threshold, 2)
    173173 
    174174    pwm = motility.make_pwm(sequences) 
     
    185185<textarea name='sequences' rows='5' cols='30'></textarea> 
    186186<p> 
    187 Threshold: <input type='text' name='default_threshold' size='5'> 
     187Threshold: <input type='text' name='default_threshold' size='7'> 
    188188 
    189189<p> 
    190 <input type='submit' value='save changes'> 
    191190<input type='submit' value='save & return to motif list' name='return'> 
     191<input type='submit' value='save & update information'> 
    192192<input type='reset' value='reset form'> 
    193193</form> 
  • trunk/cartwheel-server/website/canal/motif/analyze.ptl

    r276 r279  
    11""" 
    22Web handler for dealing with sequence analysis by motifs. 
     3 
     4CTB to test: 
     5  - empty annotations 
    36""" 
    47 
     
    2629    Do the motif search & use pygr_draw to actually draw a picture. 
    2730    """ 
    28      
     31 
    2932    sequencedb = dict(sequence=pygr.sequence.Sequence(dna_seq.seq,'sequence')) 
    3033    colors = picture_class.colors 
     
    4649            d[name] = Annotation(name, 'sequence', start, stop, 
    4750                                 color=color) 
     51 
     52        if not d: 
     53            continue 
    4854 
    4955        map = pygr_draw.create_annotation_map(d, sequencedb) 
     
    94100        <h4>Motif matches graphed against sequence:</h4> 
    95101        <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%%'
    97103        <p> 
    98104        """ % (start, stop, start, stop) 
     
    137143 
    138144    def draw_png(self, request): 
    139         form = request.form 
    140         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 image 
     145       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 
    154160 
    155161    def draw_pdf(self, request): 
  • trunk/cartwheel-server/website/canal/motif/pages.ptl

    r278 r279  
    101101        Name: <input type='text'  name='name'> <p> 
    102102        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' 
    104104              name='mismatches' size='4' value='0'><p> 
    105105              <input type='submit' value='add IUPAC motif'> 
    106106        </form> 
     107<p> 
     108IUPAC codes: 
     109<blockquote><pre> 
     110A            A           Adenine 
     111C            C           Cytosine 
     112G            G           Guanine 
     113T            T           Thymine 
     114U            U           Uracil 
     115M          A or C 
     116R          A or G 
     117W          A or T 
     118S          C or G 
     119Y          C or T 
     120K          G or T 
     121V        A or C or G 
     122H        A or C or T 
     123D        A or G or T 
     124B        C or G or T 
     125N      G or A or T or C 
     126</pre></blockquote> 
    107127        """ 
    108128 
     
    278298    "<table border='1'>" + "\n".join(x) + "</table>" 
    279299 
     300    consensus = motility.make_iupac_motif(sequences) 
     301    """ 
     302    <p> 
     303    Consensus motif for this matrix: %s 
     304    <p> 
     305    """ % (consensus,) 
     306 
    280307    ### 
    281308 
     
    308335    """ 
    309336    <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  
    5151            errors.append('Maximum threshold for this matrix motif is %g (which is less than %g)' % (pwm.max_score(), threshold)) 
    5252 
    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!") 
    5657 
    5758    ##