Retrieves a sequence from an opened multifasta file

    :param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+')
    :param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2)

    returns: a string with the sequence of interest

def getFasta(opened_file, sequence_name):
    """
    Retrieves a sequence from an opened multifasta file

    :param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+')
    :param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2)

    returns: a string with the sequence of interest
    """

    lines = opened_file.readlines()
    seq=str("")
    for i in range(0, len(lines)):
        line = lines[i]
        if line[0] == ">":
            fChr=line.split(" ")[0].split("\n")[0]
            fChr=fChr[1:]
            if fChr == sequence_name:
                s=i
                code=['N','A','C','T','G']
                firstbase=lines[s+1][0]
                while firstbase in code:
                    s=s + 1
                    seq=seq+lines[s]
                    firstbase=lines[s+1][0]

    if len(seq)==0:
        seq=None
    else:
        seq=seq.split("\n")
        seq="".join(seq)

    return seq