Assuming the file has a format similar to this:
>SEQUENCE 1
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
LVSVKVSDDFTIAAMRPSYLSYEDLDMTFVENEYKALVAELEKENEERRRLKDPNKPEHK
IPQFASRKQLSDAILKEAEEKIKEELKAQGKPEKIWDNIIPGKMNSFIADNSQLDSKLTL
MGQFYVMDDKKTVEQVIAEKEKEFGGKIKIVEFICFEVGEGLEKKTEDFAAEVAAQL
>SEQUENCE 2
SATVSEINSETDFVAKNDQFIALTKDTTAHIQSNSLQSVEELHSSTINGVKFEEYLKSQI
ATIGENLVVRRFATLKAGANGVVNGYIHTNGRVGVVIAAACDSAEVASKSRDLLRQICMH
I assume that what you want to remove are the lines with this format >SEQUENCE xxxx
(or similar), beforehand I already tell you that I do not understand anything of this format, except what I read in Wikipedia a little, but I think your goal is simple, if it is really just read line by line from FASTA file.
arquivo = 'foo.dat'; # Seu arquivo "fasta"
f = open(arquivo, 'r') # Abre para leitura
lines = f.readlines() # Lê as linhas e separa em um vetor
relist = [] # cria um novo array para pegar somente as linhas de interesse
for line in lines:
if line.find('>') != 0: # ignora as linhas que começam com >
relist.append(line)
print(relist) # Mostra o array no output
Now if what you want is to actually remove the first line, whatever it is, just use .pop(0)
, thus:
arquivo = 'foo.dat';
f = open(arquivo, 'r')
lines = f.readlines() # Lê as linhas e separa em um vetor
firstLine = f.pop(0) #Remove a primeira linha
print(lines)
To make the array
in string
("text") just use the str.join(array)
, should look like this for the first example:
''.join(relist)
And so for the second:
''.join(lines)
Can you read a whole line? If so, do the first reading and throw it in the trash
– Jefferson Quesado
Can I explain it better? What is the content of the file exactly? Which line do you want to delete? You’ve already been able to read the file with Python?
– Woss
ctagc
reminds me of DNA reading. Electrophoresis?– Jefferson Quesado
@Jeffersonquesado edited the question. Maybe it gets easier :)
– Guilherme Nascimento
What you mean by 'first line'? in what you called example, has how many lines? You can show a part of a real file?
– Sidon
@Guilhermenascimento much better! And it really had to do with bioinformatics, think of a well-given kick
– Jefferson Quesado
@Jeffersonquesado was really :D
– Guilherme Nascimento