Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/FASTA-format/Python/fasta-format.py
Normal file
25
Task/FASTA-format/Python/fasta-format.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import io
|
||||
|
||||
FASTA='''\
|
||||
>Rosetta_Example_1
|
||||
THERECANBENOSPACE
|
||||
>Rosetta_Example_2
|
||||
THERECANBESEVERAL
|
||||
LINESBUTTHEYALLMUST
|
||||
BECONCATENATED'''
|
||||
|
||||
infile = io.StringIO(FASTA)
|
||||
|
||||
def fasta_parse(infile):
|
||||
key = ''
|
||||
for line in infile:
|
||||
if line.startswith('>'):
|
||||
if key:
|
||||
yield key, val
|
||||
key, val = line[1:].rstrip().split()[0], ''
|
||||
elif key:
|
||||
val += line.rstrip()
|
||||
if key:
|
||||
yield key, val
|
||||
|
||||
print('\n'.join('%s: %s' % keyval for keyval in fasta_parse(infile)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue