[Phyton] Pomoc w napisaniu funkcji

Witam!

Czy mogłby mi ktoś pomóc w napisaniu funkcji readFastaAlignment, która będzie wczytywać plik z dopasowaniem w formacie FASTA a następnie będzie zwracać w postaci listy, której każdym z elementów będzie dwuelementowa krotka zawierająca opis sekwencji oraz samą sekwencje.

Dodam tyle że plik o rozszerzeniu FASTA otrzymuje z programu:

#!/usr/bin/python

import re

ENTRIES = re.compile('name\s+?(\S+).+?sequence\s+?([^\}]+)',re.S)

FASTA_ALN = True


def convert(options,linewidth=60):

    try: f = open(options.inputfile,'r')

    except IOError: raise " File '%s' not found." % options.inputfile

    data = f.read()

    f.close()

    entries = re.findall(ENTRIES,data)

    f = open(options.outputfile,'w')

    for name, sequence in entries:

        f.write('>%s\n' % name)

        if FASTA_ALN: 

            cleaned = re.subn('\s','',sequence)[0].upper()

            cleaned = re.subn('\.','-',cleaned)[0].upper() + '\n'

        else: cleaned = re.subn('[\s\.]','',sequence)[0].upper()

        f.write('\n'.join([cleaned[i] \

                           for i in range(0,len(sequence),linewidth)]))

    f.close()


def main():

    from optparse import OptionParser


    usage = """ %prog [options]

 program for convertion biological sequence data from RST to Fasta format """

    parser = OptionParser(usage=usage)

    parser.add_option('-i', '--input', help='input RST filename',

                      action='store', type='string', dest='inputfile')

    parser.add_option('-o', '--output', help='output FASTA filename',

                      action='store', type='string', dest='outputfile',

                      default='sequence.fasta')

    options, args = parser.parse_args()

    if not options.inputfile:

       parser.error(" You MUST provide input filename. "+\

                    "Run program with '-h' for help.")

    convert(options)

if __name__ == ' __main__': main()

który ze zbiorów RSF wybiera odpowiednie sekwencje (wyrażenia regularne) i zapisuje je do pliku FASTA.

Sytem na ktorym pracuje: Ubuntu