Changeset 311 for trunk/vertex

Show
Ignore:
Timestamp:
05/05/08 10:57:51 (7 months ago)
Author:
t
Message:

added some motif stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/vertex/lib/vertex/web/user.py

    r310 r311  
    1010          'ret' : 'chr6:5,788,957-6,042,376', 
    1111          'slit1' : 'chr6:23,800,220-23,852,953', 
    12           'foxd3' : 'chr8:28,540,680-28,566,644', 
     12          'foxd3' : 'chr8:28514716-28592608', 
    1313          'sox10' : 'chr1:52,958,231-53,024,630' } 
    1414 
     
    1717               'ret-c' : 'chr6:5,985,800-5,986,800', 
    1818               'ret-d' : 'chr6:5,890,500-5,891,000', 
    19                'ret-e' : 'chr6:5,894,800-5,895,100' } 
    20  
    21 motifs = { 'WGATAR' : 'purple', 
     19               'ret-e' : 'chr6:5,894,800-5,895,100', 
     20               'foxd3.3' : 'chr8:28,516,163-28,518,242', 
     21               'foxd3.9' : 'chr8:28,541,367-28,542,246'} 
     22 
     23motifs = { 'WGATARA' : 'purple', 
    2224           'AGCGGA' : 'green', 
    2325           'GGGTTGC' : 'red' } 
     
    2931    Top-level user interface. 
    3032    """ 
    31     _q_exports = ['', 'v'
     33    _q_exports = ['', 'v', 'add_motif', 'delete_motif'
    3234     
    3335    def __init__(self, username): 
     
    5860        s += "Constructs: <ul><li>" + "<li>".join(x) + "</ul>" 
    5961 
     62        s += "<hr>" 
     63 
     64        if motifs: 
     65            x = [] 
     66            for k in motifs: 
     67                x.append("<tt>%s</tt>: %s <a href='delete_motif?iupac=%s'>[delete]</a>" % (k, motifs[k], k)) 
     68            s += "Motifs: <ul><li>" + "<li>".join(x) + "</ul>" 
     69 
     70        s += "<form method='POST' action='add_motif'>Add motif: <input type='text' name='iupac'> <select name='color'><option value='red'> red<option value='blue'> blue</select><input type='submit' value='add'></form>" 
     71 
    6072        return s 
     73 
     74    def add_motif(self): 
     75        request = quixote.get_request() 
     76        iupac = request.form['iupac'].strip().upper() 
     77        color = request.form['color'] 
     78 
     79        motifs[iupac] = color 
     80 
     81        make_motif_nlmsa() 
     82 
     83        return quixote.redirect('./') 
     84 
     85    def delete_motif(self): 
     86        request = quixote.get_request() 
     87        iupac = request.form['iupac'] 
     88 
     89        if iupac in motifs: 
     90            del motifs[iupac] 
     91 
     92        make_motif_nlmsa() 
     93         
     94        return quixote.redirect('./') 
    6195 
    6296### 
     
    76110        maps.append(constructs_nlmsa) 
    77111 
    78         maps.append(motif_nlmsa) 
     112        if motif_nlmsa: 
     113            maps.append(motif_nlmsa) 
    79114 
    80115        colors = [ 'red', 'black', 'blue', 'black' ] 
     
    132167        x = [] 
    133168        for motif, color in motifs.items(): 
    134             x.append('%s (%s)' % (motif, color,)) 
     169            x.append('<tt>%s</tt> (%s)' % (motif, color,)) 
    135170        motiflist = ", ".join(x) 
    136171 
     
    154189<p> 
    155190Motifs: %s 
     191<p> 
    156192<img src='draw/%s' width='1000'> 
    157193""" % (view, where, size, size / 1000, where, 
     
    208244    return nlmsa 
    209245 
    210 data.load() 
    211  
    212 x = [] 
    213 for v in views.values(): 
    214     (chr, start, stop) = coords.translate(v) 
    215     subseq = data.genome[chr][start:stop] 
    216     x.append(subseq) 
    217  
    218 motif_nlmsa = make_motif_search_nlmsa(data.genome, x, motifs) 
     246motif_nlmsa = None 
     247def make_motif_nlmsa(): 
     248    global motif_nlmsa 
     249    data.load() 
     250 
     251    if not motifs: 
     252        motif_nlmsa = None 
     253        return 
     254 
     255    x = [] 
     256    for v in views.values(): 
     257        (chr, start, stop) = coords.translate(v) 
     258        subseq = data.genome[chr][start:stop] 
     259        x.append(subseq) 
     260 
     261    motif_nlmsa = make_motif_search_nlmsa(data.genome, x, motifs)