Hi, I'm beginner to python, here I have a very basic question about extracting targeted text. I have thousands of strings like this :
>ref|WP_070076791.1| iron-sulfur protein [Acinetobacter proteolyticus]
Here I only need WP_070076791.1, so I write a script in python:
data = open("data.fasta").read()
import re
for line in data:
start = line.startswith(">ref|")
end = line.endswith("| ")
number = re.search(r'start(.*?)end',line)
print(number)
But it gives me "none", does anybody have idea?
I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below: