Advertisement
davide1409

searchNucleotidi

Nov 18th, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def searchNucleotidi(subs):
  2. #@param subs: string; stringa di nucleotidi da cercare
  3.   path = pickAFile()
  4.   if path[len(path)-4:] != '.txt':
  5.     return None
  6.              
  7.   res = ''
  8.   file = open(path,'rt')
  9.   s = file.read()
  10.  
  11.   pos = s.find(subs)
  12.  
  13.   if pos != -1:
  14.     res+='Found in '
  15.   else:
  16.     res+='Not found'
  17.     return res
  18.  
  19.   maggiore = s.rfind('>',0,pos)+1
  20.   a_capo = s.find('\n',maggiore)
  21.  
  22.   res+=s[maggiore:a_capo]
  23.  
  24.   file.close()
  25.  
  26.   return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement