Example #1
0
def InferSingleLettterCode(threlettercode):
    '''
    Convert the amino acid three letter code, into a single letter code
    '''
    from tl.rename.case import transform_sentence_case
    aa = {
        'Gly': 'G',
        'Ala': 'A',
        'Val': 'V',
        'Leu': 'L',
        'Ile': 'I',
        'Met': 'M',
        'Phe': 'F',
        'Trp': 'W',
        'Pro': 'P',
        'Ser': 'S',
        'Thr': 'T',
        'Cys': 'C',
        'Tyr': 'Y',
        'Asn': 'N',
        'Gln': 'Q',
        'Asp': 'D',
        'Glu': 'E',
        'Lys': 'K',
        'Arg': 'R',
        'His': 'H'
    }
    singleletter = aa[transform_sentence_case([threlettercode])[0]]
    return singleletter
Example #2
0
def clean_string(instr, change_case=True):
    '''
    Clean string: change \n to <br /> and escape ampersand 
    ''' 
    cleaned_string = instr.replace('\n', '<br />').replace('&', '&amp;')
    if(get_config('clean_string_sentence_case') == 'True' and change_case): 
        cleaned_string = transform_sentence_case([cleaned_string])[0]
    
    return cleaned_string
Example #3
0
def InferSingleLettterCode(threlettercode):
    '''
    Convert the amino acid three letter code, into a single letter code
    '''
    from tl.rename.case import transform_sentence_case
    aa = {'Gly':'G' , 'Ala':'A' , 'Val':'V' , 'Leu':'L' , 'Ile':'I' , 'Met':'M' , 'Phe':'F' ,
          'Trp':'W' , 'Pro':'P' , 'Ser':'S' , 'Thr':'T' , 'Cys':'C' , 'Tyr':'Y' , 'Asn':'N' , 
          'Gln':'Q' , 'Asp':'D' , 'Glu':'E' , 'Lys':'K' , 'Arg':'R' , 'His':'H'}
    singleletter = aa[transform_sentence_case([threlettercode])[0]]
    return singleletter
def report_qec_interest_areas(request):    
    
#    class ReportForm(forms.Form):
#        semester = forms.ChoiceField(choices=SEMESTER_CHOICES)
#        year = forms.CharField()
#        
#    c = RequestContext(request)  
#    c.update(csrf(request))
    
        
    all_areas = {}
    inst_areas = []

    instructors = InstructorProfile.objects.all()

    
    for i in instructors: 
         areas = i.areas_of_interest
         inst_areas.append(['<b>' + unicode(i) + '</b> (' + i.designation + '): ', areas.strip().replace('\n', '; ')])
         
         areas = re.split("\n", areas)
         
         for a in areas:
             if a.upper() != a:  # leave all caps alone 
                a = a.strip().lower()
             if a == '': continue 
             
             try: 
                 all_areas[a] = all_areas[a] + 1
             except: 
                 all_areas[a] = 1


    areas = {}
    for area, count in all_areas.items():
        if area.upper() != area: # leave all caps alone 
            area = transform_sentence_case([area])[0]
        areas[area] = count
        
    


    # prepare list of courses [{'Course Name' : course_name, 'Course Code' : course_name }
    #                             , {...}] 
                
    return render_to_response('qec_interest_areas.html' , {
        'areas' : areas,
        'inst_areas' : inst_areas,
        })
Example #5
0
from numpy import median

filename = sys.argv[1]
col = int(sys.argv[2]) #number of columns
f = open(filename).read().split('\n')
#parse the equivalences file
sps = {}
for e in f:
    if e == '' or e == '\t\t':
        continue
    else:
        bline = e.split('\t')
        sp = bline[0].split('_')[0]
        sp = sp.split()        
        if 'SP.' in bline[0]:
            sp = transform_sentence_case([sp[0]])[0]+' '+transform_lowercase([sp[1]])[0]
        else:
            sp = ' '.join(sp)#sp[0][0]+'. '+transform_lowercase([sp[1]])[0]
            
        pdb=bline[1]
        ind=bline[2]
        if not sp in sps:
            sps[sp]= []
            sps[sp].append((pdb,ind))
        else:
            sps[sp].append((pdb,ind))

#create the table
t = open(filename[:filename.rfind('.')]+'.latextable','w')
header ='\\begin{table}[ht]\n\t\\tiny\n\t\\caption{}\n\t\\begin{center}\n\\begin{tabular}{ ccc'+' cc'*(col-1)
header += '}\n\t\\toprule\n\t Species'+ '& PDB & Plot'*col +'\\\\\n'
Example #6
0
from numpy import median

filename = sys.argv[1]
col = int(sys.argv[2])  #number of columns
f = open(filename).read().split('\n')
#parse the equivalences file
sps = {}
for e in f:
    if e == '' or e == '\t\t':
        continue
    else:
        bline = e.split('\t')
        sp = bline[0].split('_')[0]
        sp = sp.split()
        if 'SP.' in bline[0]:
            sp = transform_sentence_case(
                [sp[0]])[0] + ' ' + transform_lowercase([sp[1]])[0]
        else:
            sp = ' '.join(sp)  #sp[0][0]+'. '+transform_lowercase([sp[1]])[0]

        pdb = bline[1]
        ind = bline[2]
        if not sp in sps:
            sps[sp] = []
            sps[sp].append((pdb, ind))
        else:
            sps[sp].append((pdb, ind))

#create the table
t = open(filename[:filename.rfind('.')] + '.latextable', 'w')
header = '\\begin{table}[ht]\n\t\\tiny\n\t\\caption{}\n\t\\begin{center}\n\\begin{tabular}{ ccc' + ' cc' * (
    col - 1)