I wrote a function and call it as below:
from lib import base_frequency
base_frequency("AB610939-AB610950.gb", "genbank")
#This calls the function that uses a BioPython code.
How could I pass the function arguments as below?
base_frequency(AB610939-AB610950.gb, genbank)
Note that quotes are missing. Should I do this? Is there a recommended nomenclature in Python when function argument is sting?
I thought this required me to convert filename and record format to a string inside the function. That is:
AB610939-AB610950.gb to "AB610939-AB610950.gb"
genbank to "genbank"
I have tried str(AB610939-AB610950.gb)
inside the function but it did not do the job.
There is no way to do this without quotes, or else Python will interpret it as an expression. Take the first argument for example,
AB610939-AB610950.gb
Python will read this as a subtraction operation between two variables, AB610939
and the gb
property of AB610950
, not a sequence of characters. The only way to stop this is to surround it in quotation marks to make it string literal.