Mercurial > repos > davidmurphy > codonlogo
diff weblogolib/__init__.py @ 8:5149eb3a89c2
Uploaded
author | davidmurphy |
---|---|
date | Fri, 20 Jan 2012 09:03:40 -0500 |
parents | 4d47ab2b7bcc |
children | f3462128e87c |
line wrap: on
line diff
--- a/weblogolib/__init__.py Mon Jan 16 07:03:36 2012 -0500 +++ b/weblogolib/__init__.py Fri Jan 20 09:03:40 2012 -0500 @@ -132,6 +132,7 @@ altype="codonsT" offset=0 isreversed=False +show_warnings=False col=[] @@ -169,7 +170,7 @@ description = "Create sequence logos from biological sequence alignments." -__version__ = "1.0" +__version__ = "1.1" # These keywords are subsituted by subversion. # The date and revision will only tell the truth after a branch or tag, @@ -312,9 +313,9 @@ # Check that can get 80 characters in journal page @small # 40 chacaters in a journal column std_sizes = { - "small" : LogoSize( stack_width = 10, stack_height = 10*1*5), - "medium" : LogoSize( stack_width = 10*2, stack_height = 10*2*5), - "large" : LogoSize( stack_width = 10*3, stack_height = 10*3*5), + "small" : LogoSize( stack_width = 16.2, stack_height = 10*1*5), + "medium" : LogoSize( stack_width = 16.2*2, stack_height = 10*2*5), + "large" : LogoSize( stack_width = 16.2*3, stack_height = 10*3*5), } @@ -439,6 +440,7 @@ self.yaxis_scale = None self.show_xaxis = True + self.strict=False self.xaxis_label = "" self.xaxis_tic_interval =1 self.rotate_numbers = False @@ -798,7 +800,7 @@ "errorbar_width_fraction", "errorbar_gray", "small_fontsize", "fontsize", "title_fontsize", "number_fontsize", "text_font", - "logo_font", "title_font", + "logo_font", "title_font", "strict", "logo_label", "yaxis_scale", "end_type", "debug", "show_title", "show_xaxis", "show_xaxis_label", "show_yaxis", "show_yaxis_label", @@ -930,6 +932,8 @@ # Create and output logo template = resource_string( __name__, 'template.eps', __file__) + + logo = Template(template).substitute(subsitutions) print >>fout, logo @@ -1248,6 +1252,14 @@ if len(str(seqs[i][(counter):(counter+3)]))==3 and len(seqs[i][(counter):(counter+3)].strip("GATUC"))==0 : if(str(seqs[i][(counter):(counter+3)]) in alphabet): x[counter/3][ (alphabet.index(str(seqs[i][(counter):(counter+3)]))) ]+=1 + elif show_warnings: + if len(seqs[i][(counter):(counter+3)].strip("GATUC"))==1 or len(seqs[i][(counter):(counter+3)].strip("GATUC"))==2 : + print >>sys.stderr, 'Warning:Incomplete or non GATUC codon detected:', seqs[i][(counter):(counter+3)] + print >>sys.stderr, 'Position:',counter + print >>sys.stderr, 'Sequence:',i + print >>sys.stderr, 'This will be treated as ---' + + counter=counter+3 counts=asarray(x) else: @@ -1369,12 +1381,19 @@ if not line: break line = line.split() - priordict[line[0]]=line[1] - return priordict + + if(altype=="codonsT"): + priordict[line[0].upper().replace("U", "T")]=(float(line[1])/1000)*64 + else: + priordict[line[0].upper().replace("T", "U")]=(float(line[1])/1000)*64 + + return priordict def _build_logodata(options) : global offset offset=options.frame + global show_warnings + show_warnings = options.strict options.alphabet = None options.ignore_lower_case = False #options.default_color = Color.by_name("black") @@ -1384,7 +1403,7 @@ seqs = read_seq_data(options.fin, options.input_parser.read, alphabet=options.alphabet, - ignore_lower_case = options.ignore_lower_case) + ignore_lower_case = options.ignore_lower_case) if(options.priorfile!=None): if(altype=="CodonsT"): options.composition= str(read_priors(options.priorfile,codon_alphabetT)) @@ -1408,6 +1427,7 @@ "logo_title", "yaxis_label", "show_xaxis", + "strict", "show_yaxis", "xaxis_label", "show_ends", @@ -1644,7 +1664,13 @@ type="int", help="Upper bound of sequence to display", metavar="INDEX") - + + data_grp.add_option( "-G", "--strict", + dest="strict", + action="store", + type="boolean", + help="Issue warnings if partial codons are encountered. Default: %default",default = defaults.strict, + metavar="True/False") # ========================== FORMAT OPTIONS ========================== format_grp.add_option( "-s", "--size",