My professor wants us to make a program that analyses triplets in sequences. The first step is to open and read the actual sequence and he provides these codes.
def read_FASTA(fname):
begin = True
prots = {}
fil = open(fname, "rt")
lins = fil.readlines()
fil.close()
for lin in lins:
slin = lin.strip()
if slin[0] == '>':
if begin == False:
prots[pname] = seq
seq = ""
pname = slin[1:].strip()
begin = False
else:
seq = seq + slin
prots[pname] = seq
return prots
---SECOND CODE---
import rfasta
prots = rfasta.read_FASTA(‘C:\Users\hdini\Desktop\aasd\\proteinas.fasta’)
for prot in prots:
print(prot)
After downloading the fasta file from Uniprot(one or multiple), these are my results:
def read_FASTA("proteinas.fasta"):
begin = True
prots = {}
fil = open("proteinas.fasta", "rt")
lins = fil.readlines()
fil.close()
for lin in lins:
slin = lin.strip()
if slin[0] == '>':
if begin == False:
prots[pname] = seq
seq = ""
pname = slin[1:].strip()
begin = False
else:
seq = seq + slin
prots[pname] = seq
return prots
--Second result--
import rfasta
prots = rfasta.read_FASTA(‘C:\Users\hdini\Desktop\aasd\\proteinas.fasta')
for prot in prots:
print(prot)
I suspect this is just the tip of the iceberg, but at least part of your problem is that you are passing your file path with a mixture of quotes and backticks:
Do not mix these up. It should look something like:
function('C:\Path\to\file.fasta')
——
Just a pointer about using the forum, please don’t screenshot code/output, instead copy and paste the text and format it appropriately as I have done above.
But i did put in single quotes!
Hummm.. perhaps it was just that screenshot making it look odd then (another reason to copy the raw text).
And what was the error you were getting again?
Hello hdinis09 ,
you forgot to tell us, what your question/problem is :)
fin swimmer