scripts/export/genomes/genome_fetch.py
def assembly_report_parser(assembly_report, url=True):
    """
    Parses an assembly report file and returns a list of all available
    accessions (scaffolds, contigs etc)

    report_url: A url provided within an ENA assembly xml file. This is the
    text of URL tag under ASSEMBLY/ASSEMBLY_LINKS/ASSEMBLY_LINK.By default this
    is an ftp request url. Converting to http to fetch assembly accessions.
    """

    accessions = []

    # switch from ftp to http to fetch assembly accessions on the go
    report_url = None
    ass_rep_file = None

    if url is True:
        report_url = assembly_report.replace("ftp://", "http://")
        # fetch assembly report file contents and store in a list, omitting header
        ass_rep_file = requests.get(report_url).content.split('\n')[1:]

        # if empty line, remove it
        if ass_rep_file[len(ass_rep_file) - 1] == '':
            ass_rep_file.pop(len(ass_rep_file) - 1)
    else:
        ass_rep_file = open(assembly_report, 'r')

    # parse list and export assembly accessions
    for line in ass_rep_file:
        line = line.strip().split('\t')
        if line[0].find('.') != -1:
            accessions.append(line[0])

    return accessions

    Parses an assembly report file and returns a list of all available
    accessions (scaffolds, contigs etc)

    report_url: A url provided within an ENA assembly xml file. This is the
    text of URL tag under ASSEMBLY/ASSEMBLY_LINKS/ASSEMBLY_LINK.By default this
    is an ftp request url. Converting to http to fetch assembly accessions.
    
Parses an assembly report file and returns a list of all available
accessions (scaffolds, contigs etc)

A url provided within an ENA assembly xml file. This is the
text of URL tag under ASSEMBLY/ASSEMBLY_LINKS/ASSEMBLY_LINK.By default this
is an ftp request url. Converting to http to fetch assembly accessions.
Parses an assembly report file and returns a list of all available accessions ( scaffolds contigs etc ) A url provided within an ENA assembly xml file . This is the text of URL tag under ASSEMBLY / ASSEMBLY_LINKS / ASSEMBLY_LINK . By default this is an ftp request url . Converting to http to fetch assembly accessions .
def assembly_report_parser(assembly_report, url=True):
    accessions = []
    report_url = None
    ass_rep_file = None
    if url is True:
        report_url = assembly_report.replace("ftp://", "http://")
        ass_rep_file = requests.get(report_url).content.split('\n')[1:]
        if ass_rep_file[len(ass_rep_file) - 1] == '':
            ass_rep_file.pop(len(ass_rep_file) - 1)
    else:
        ass_rep_file = open(assembly_report, 'r')
    for line in ass_rep_file:
        line = line.strip().split('\t')
        if line[0].find('.') != -1:
            accessions.append(line[0])
    return accessions
def assembly_report_parser ( assembly_report , url = True ) : accessions = [ ] report_url = None ass_rep_file = None if url is True : report_url = assembly_report . replace ( "ftp://" , "http://" ) ass_rep_file = requests . get ( report_url ) . content . split ( '\n' ) [ 1 : ] if ass_rep_file [ len ( ass_rep_file ) - 1 ] == '' : ass_rep_file . pop ( len ( ass_rep_file ) - 1 ) else : ass_rep_file = open ( assembly_report , 'r' ) for line in ass_rep_file : line = line . strip ( ) . split ( '\t' ) if line [ 0 ] . find ( '.' ) != - 1 : accessions . append ( line [ 0 ] ) return accessions
Parses an assembly report file and returns a list of all available
accessions (scaffolds, contigs etc)
Parses an assembly report file and returns a list of all available accessions ( scaffolds contigs etc )
"""
    Parses an assembly report file and returns a list of all available
    accessions (scaffolds, contigs etc)

    report_url: A url provided within an ENA assembly xml file. This is the
    text of URL tag under ASSEMBLY/ASSEMBLY_LINKS/ASSEMBLY_LINK.By default this
    is an ftp request url. Converting to http to fetch assembly accessions.
    """ # switch from ftp to http to fetch assembly accessions on the go # fetch assembly report file contents and store in a list, omitting header # if empty line, remove it # parse list and export assembly accessions
assembly_report
url