Package Bio :: Module lcc
[hide private]
[frames] | no frames]

Source Code for Module Bio.lcc

  1  # Copyright 2003 by Sebastian Bassi. sbassi@genesdigitales.com 
  2  # All rights reserved.  This code is part of the Biopython  
  3  # distribution and governed by its license. 
  4  # Please see the LICENSE file that should have been included as part 
  5  # of this package. 
  6   
  7  import warnings 
  8  warnings.warn("Bio.lcc is deprecated; it has been moved to Bio.SeqUtils.lcc instead", DeprecationWarning) 
  9   
 10  import math 
 11  from string import count 
 12   
 13  crom=0 
 14  compone=[0] 
 15  lccsal=[0] 
 16   
17 -def lcc_mult(seq,wsize,start,end):
18 """Return a list called lccsal, the LCC, a complexity measure 19 from a sequence, called seq.""" 20 l2=math.log(2) 21 tamseq=end-start 22 global compone 23 global lccsal 24 compone=[0] 25 lccsal=[0] 26 for i in range(wsize): 27 compone.append(((i+1)/float(wsize))*((math.log((i+1)/float(wsize)))/l2)) 28 window=seq[0:wsize] 29 cant_a=count(window,'A') 30 cant_c=count(window,'C') 31 cant_t=count(window,'T') 32 cant_g=count(window,'G') 33 term_a=compone[cant_a] 34 term_c=compone[cant_c] 35 term_t=compone[cant_t] 36 term_g=compone[cant_g] 37 lccsal[0]=(-(term_a+term_c+term_t+term_g)) 38 tail=seq[0] 39 for x in range (tamseq-wsize): 40 window=seq[x+1:wsize+x+1] 41 if tail==window[-1]: 42 lccsal.append(lccsal[-1]) 43 #break 44 elif tail=='A': 45 cant_a=cant_a-1 46 if window[-1]=='C': 47 cant_c=cant_c+1 48 term_a=compone[cant_a] 49 term_c=compone[cant_c] 50 lccsal.append(-(term_a+term_c+term_t+term_g)) 51 elif window[-1]=='T': 52 cant_t=cant_t+1 53 term_a=compone[cant_a] 54 term_t=compone[cant_t] 55 lccsal.append(-(term_a+term_c+term_t+term_g)) 56 elif window[-1]=='G': 57 cant_g=cant_g+1 58 term_a=compone[cant_a] 59 term_g=compone[cant_g] 60 lccsal.append(-(term_a+term_c+term_t+term_g)) 61 elif tail=='C': 62 cant_c=cant_c-1 63 if window[-1]=='A': 64 cant_a=cant_a+1 65 term_a=compone[cant_a] 66 term_c=compone[cant_c] 67 lccsal.append(-(term_a+term_c+term_t+term_g)) 68 elif window[-1]=='T': 69 cant_t=cant_t+1 70 term_c=compone[cant_c] 71 term_t=compone[cant_t] 72 lccsal.append(-(term_a+term_c+term_t+term_g)) 73 elif window[-1]=='G': 74 cant_g=cant_g+1 75 term_c=compone[cant_c] 76 term_g=compone[cant_g] 77 lccsal.append(-(term_a+term_c+term_t+term_g)) 78 elif tail=='T': 79 cant_t=cant_t-1 80 if window[-1]=='A': 81 cant_a=cant_a+1 82 term_a=compone[cant_a] 83 term_t=compone[cant_t] 84 lccsal.append(-(term_a+term_c+term_t+term_g)) 85 elif window[-1]=='C': 86 cant_c=cant_c+1 87 term_c=compone[cant_c] 88 term_t=compone[cant_t] 89 lccsal.append(-(term_a+term_c+term_t+term_g)) 90 elif window[-1]=='G': 91 cant_g=cant_g+1 92 term_t=compone[cant_t] 93 term_g=compone[cant_g] 94 lccsal.append(-(term_a+term_c+term_t+term_g)) 95 elif tail=='G': 96 cant_g=cant_g-1 97 if window[-1]=='A': 98 cant_a=cant_a+1 99 term_a=compone[cant_a] 100 term_g=compone[cant_g] 101 lccsal.append(-(term_a+term_c+term_t+term_g)) 102 elif window[-1]=='C': 103 cant_c=cant_c+1 104 term_c=compone[cant_c] 105 term_g=compone[cant_g] 106 lccsal.append(-(term_a+term_c+term_t+term_g)) 107 elif window[-1]=='T': 108 cant_t=cant_t+1 109 term_t=compone[cant_t] 110 term_g=compone[cant_g] 111 lccsal.append(-(term_a+term_c+term_t+term_g)) 112 tail=window[0] 113 return lccsal
114
115 -def lcc_simp(seq,start,end):
116 """Return LCC, a complexity measure from a sequence (seq.)""" 117 wsize=end-start 118 l2=math.log(2) 119 window=seq[start:end] 120 if count(window,'A')==0: 121 term_a=0 122 # This check is usefull in order to avoid calculate log of 0. 123 else: 124 term_a=((count(window,'A'))/float(wsize))*((math.log((count(window,'A'))/float(wsize)))/l2) 125 if count(window,'C')==0: 126 term_c=0 127 else: 128 term_c=((count(window,'C'))/float(wsize))*((math.log((count(window,'C'))/float(wsize)))/l2) 129 if count(window,'T')==0: 130 term_t=0 131 else: 132 term_t=((count(window,'T'))/float(wsize))*((math.log((count(window,'T'))/float(wsize)))/l2) 133 if count(window,'G')==0: 134 term_g=0 135 else: 136 term_g=((count(window,'G'))/float(wsize))*((math.log((count(window,'G'))/float(wsize)))/l2) 137 lccsal=-(term_a+term_c+term_t+term_g) 138 return lccsal
139