daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. class Kmer:
  2.     sequence = ''    
  3.  
  4.     def __init__(self,kmer_name):
  5.         self.sequence = kmer_name
  6.         self.counter = 1
  7.         self.lst = []
  8.         self.indxx = {}
  9.    
  10.     def increase(self):
  11.         self.counter += 1
  12.        
  13.     def increase_n(self, n):
  14.         self.counter += n
  15.        
  16.     def add_locus(self, kmer_name):
  17.         self.lst = lst.append(kmer_name)
  18.     def locus_index(self, index, kmer_name):
  19.         #d1["China"]="Beijing"
  20.         self.indxx ["kmer_name"]="index"
  21.  
  22. seq = 'ATGGCTAGATCCCTACG'
  23. seq_lng = len(seq)
  24. read_lng = 5
  25. kmer_size = 3
  26. kmer_dict = {}
  27. kmer_dict_locus = {}
  28. kmer_lst = []
  29.  
  30. #for read_indx in range(seq_lng-read_lng+1):
  31. #    read = seq[read_indx:(read_indx+read_lng)]
  32. #    print(read)
  33. for index in range(seq_lng-kmer_size+1):
  34.     current_kmer = seq[index:(index+kmer_size)]
  35.    
  36.     #print(current_kmer)
  37.     if current_kmer in kmer_dict:
  38.         kmer_dict[current_kmer].increase()
  39.         kmer_dict_locus[current_kmer].locus_index()
  40.     else:
  41.         kmer_dict[current_kmer] = Kmer(current_kmer)
  42.         kmer_lst[current_kmer].add_locus()
  43.            
  44. for k,s in kmer_dict.items():
  45.     print(k,s.counter)
  46. for k,s in kmer_dict_locus.items():
  47.     print(k,s.key)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top