Hello I am pretty new to python and I want to do the following:
I have a function that opens a file, reads the file, closes the file and returns the data:
def getFastaFromFile(filename):
""" Read a fasta file (filename) from disk and return
its full contents as a string"""
inf=open(filename)
data=inf.read()
inf.close()
return data
The data that is being returned are a few lines with strings.
What I want to do is have another function that uses the data from the first function and perform the .readlines(), .readline() and .count() commands
My second function:
def printTableFromFasta(fastarec):
a= data.readlines()
for i in range(a)
b= data.readline()
c= b.count('A')
print(c)
As output I would like to print the amount of times string "A" appears for every line from the data. The problem I get with this code is that the data doesn't get recognized.