I am trying to open a file with these two functions.
def readFastaFile(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
fastarec = readFastaFile('ins.fasta')
def printTableFromFasta(fastarec):
infile = open(fastarec)
sequences = infile.read()
infile.close()
I get an error every time I try to run it:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/20183279/Documents/programmeren/huiswerkopgave3.py", line 32, in <module>
printTableFromFasta(fastarec)
File "C:/Users/20183279/Documents/programmeren/huiswerkopgave3.py", line 19, in printTableFromFasta
infile = open(fastarec) FileNotFoundError: [Errno 2] No such file or directory: '>NM_001185098.1 Homo sapiens insulin (INS), transcript variant 3, mRNA \nAGCCCTCCAGGACAGGCTGCATCAGAAGAGGCCATCAAGCAGGTCTGTTCCAAGGGCCTTTGCGTCAGGT
\nGGGCTCAGGATTCCAGGGTGGCTGGACCCCAGGCCCCAGCTCTGCAGCAGGGAGGACGTGGCTGGGCTCG
TGAAGCATGTGGGGGTGAGCCCAGGGGCCCCAAGGCAGGGCACCTGGCCTTCAGCCTGCCTCAGCCCTGC
CTGTCTCCCAGATCACTGTCCTTCTGCCATGGCCCTGTGGATGCGCCTCCTGCCCCTGCTGGCGCTGCTG
GCCCTCTGGGGACCTGACCCAGCCGCAGCCTTTGTGAACCAACACCTGTGCGGCTCACACCTGGTGGAAG
CTCTCTACCTAGTGTGCGGGGAACGAGGCTTCTTCTACACACCCAAGACCCGCCGGGAGGCAGAGGACCT
GCAGGTGGGGCAGGTGGAGCTGGGCGGGGGCCCTGGTGCAGGCAGCCTGCAGCCCTTGGCCCTGGAGGGG
TCCCTGCAGAAGCGTGGCATTGTGGAACAATGCTGTACCAGCATCTGCTCCCTCTACCAGCTGGAGAACT
ACTGCAACTAGACGCAGCCCGCAGGCAGCCCCACACCCGCCGCCTCCTGCACCGAGAGAGATGGAATAAA
GCCCTTGAACCAGCAAAA\n'
Why do I get the FileNotFoundError
?
Comments
Post a Comment