I don't still understand how the format is incorrect, please can you shed more light?, I have gotten the case own
• 0 views
•
link
# fasta_utils.py
def extract_gi_id(line):
parts = line.split("|")
if parts[0].startswith(">gi"):
return parts[1]
return None
#main.py
From fasta_utils import extract_gi_id
def get_gi_ids(filename):
with open(filename) as file:
return [extract_gi_id(line) for line in file if line[0] == '>']
But why is it saying fasta_utils is not defined
It is probably saying fasta_utils is not defined because From is capitalised (python is case senstive).
Should be
from fasta_utils import extract_gi_id
Not
From fasta_utils import extract_gi_id
Hi,
your import call is not correct.
EDIT: ok, should have corrected the formatting in the post first :/
Your import call is correct, it was just wrongly formatted in the initial post.
However, you seem to have a 'typo' : you don't have to use 'From' but 'from' (notice the uppercase vs lowercase!!)
I don't still understand how the format is incorrect, please can you shed more light?, I have gotten the case own
So it works now?
the thing was that this:
From fasta_utils import extract_gi_id
def get_gi_ids(filename):
was printed as:
From fasta_utils import extract_gi_id def get_gi_ids(filename):
(on a single line thus, which is incorrect)
Log in to answer this question.
Could you please edit your title to be specific to the issue and not general like it stands as 'Python in bioinformatics'? One exercise to contemplate how to write a good title is to picture a list of search results and envision what would best signal to you that the linked post is related to your specific issue and may contain the exact solution you seek. (Hopefully, that helps you see that 'Python in bioinformatics' would not really help you find your own question, say, 6 months from now when you may encounter the same or very similar problem.) Often it is easier to make the title better after you know the issue because sometimes as a novice it is hard to understand at first where the issue lies. More help: see the section 'Write a title that summarizes the specific problem' here that has some pointers related to posting in forums such as here.
IMPORT I am using Jupyter, the 2 code snippet I posted, I posted each in Jupyter cells, the import is supposed to work but it didn't I don't understand
Thank you very much for the insight, I appreciate it