scripts/release/uniprot_file_converter.py
def dump_new_upids_to_file(upid_gca_old, upid_gca_new, dest_dir=None):
    """
    Compares two upid_gca files from different Uniprot proteome releases
    and dumps the new upids in a new upid_gca file all resulting from the
    newer version of the proteome file (upid_gca_new). To be used for
    downloading a subset of genomes.

    upid_gca_out: A valid upid_gca file in .tsv format of an older reference
    proteome release
    upid_gca_new: A valid upid_gca file in .tsv format of a newer reference
        proteome release
    dest_dir: The path to a destination directory. Uses the directory of
    upid_gca_new if dest_dir is None

    returns: void
    """

    # open and load the accessions to a dictionary
    old_upids = {}
    upid_gca_old_fp = open(upid_gca_old, 'r')
    upid_gca_new_fp = open(upid_gca_new, 'r')

    # load old accessions
    for line in upid_gca_old_fp:
        fields = line.strip().split('\t')
        if fields[0] not in old_upids:
            old_upids[fields[0]] = fields[1:]

    upid_gca_old_fp.close()

    # loop over new upids
    upid_gca_new_fp = open(upid_gca_new, 'r')

    # if no destination directory provided, use directory of upid_gca_new
    if dest_dir is None:
        dest_dir = os.path.split(upid_gca_new)[0]

    upid_gca_out_fp = open(os.path.join(dest_dir, "new_upids.tsv"), 'w')

    for line in upid_gca_new_fp:
        fields = line.strip().split('\t')
        # check if upid in the old release
        if fields[0] not in old_upids:
            upid_gca_out_fp.write(('\t').join(fields) + '\n')

    upid_gca_out_fp.close()

    Compares two upid_gca files from different Uniprot proteome releases
    and dumps the new upids in a new upid_gca file all resulting from the
    newer version of the proteome file (upid_gca_new). To be used for
    downloading a subset of genomes.

    upid_gca_out: A valid upid_gca file in .tsv format of an older reference
    proteome release
    upid_gca_new: A valid upid_gca file in .tsv format of a newer reference
        proteome release
    dest_dir: The path to a destination directory. Uses the directory of
    upid_gca_new if dest_dir is None

    returns: void
    
Compares two upid_gca files from different Uniprot proteome releases
and dumps the new upids in a new upid_gca file all resulting from the
newer version of the proteome file (upid_gca_new). To be used for
downloading a subset of genomes.

A valid upid_gca file in .tsv format of an older reference
proteome release
upid_gca_new: A valid upid_gca file in .tsv format of a newer reference
proteome release
dest_dir: The path to a destination directory. Uses the directory of
upid_gca_new if dest_dir is None

void
Compares two upid_gca files from different Uniprot proteome releases and dumps the new upids in a new upid_gca file all resulting from the newer version of the proteome file ( upid_gca_new ) . To be used for downloading a subset of genomes . A valid upid_gca file in . tsv format of an older reference proteome release upid_gca_new : A valid upid_gca file in . tsv format of a newer reference proteome release dest_dir : The path to a destination directory . Uses the directory of upid_gca_new if dest_dir is None void
def dump_new_upids_to_file(upid_gca_old, upid_gca_new, dest_dir=None):
    old_upids = {}
    upid_gca_old_fp = open(upid_gca_old, 'r')
    upid_gca_new_fp = open(upid_gca_new, 'r')
    for line in upid_gca_old_fp:
        fields = line.strip().split('\t')
        if fields[0] not in old_upids:
            old_upids[fields[0]] = fields[1:]
    upid_gca_old_fp.close()
    upid_gca_new_fp = open(upid_gca_new, 'r')
    if dest_dir is None:
        dest_dir = os.path.split(upid_gca_new)[0]
    upid_gca_out_fp = open(os.path.join(dest_dir, "new_upids.tsv"), 'w')
    for line in upid_gca_new_fp:
        fields = line.strip().split('\t')
        if fields[0] not in old_upids:
            upid_gca_out_fp.write(('\t').join(fields) + '\n')
    upid_gca_out_fp.close()
def dump_new_upids_to_file ( upid_gca_old , upid_gca_new , dest_dir = None ) : old_upids = { } upid_gca_old_fp = open ( upid_gca_old , 'r' ) upid_gca_new_fp = open ( upid_gca_new , 'r' ) for line in upid_gca_old_fp : fields = line . strip ( ) . split ( '\t' ) if fields [ 0 ] not in old_upids : old_upids [ fields [ 0 ] ] = fields [ 1 : ] upid_gca_old_fp . close ( ) upid_gca_new_fp = open ( upid_gca_new , 'r' ) if dest_dir is None : dest_dir = os . path . split ( upid_gca_new ) [ 0 ] upid_gca_out_fp = open ( os . path . join ( dest_dir , "new_upids.tsv" ) , 'w' ) for line in upid_gca_new_fp : fields = line . strip ( ) . split ( '\t' ) if fields [ 0 ] not in old_upids : upid_gca_out_fp . write ( ( '\t' ) . join ( fields ) + '\n' ) upid_gca_out_fp . close ( )
Compares two upid_gca files from different Uniprot proteome releases
and dumps the new upids in a new upid_gca file all resulting from the
newer version of the proteome file (upid_gca_new).
Compares two upid_gca files from different Uniprot proteome releases and dumps the new upids in a new upid_gca file all resulting from the newer version of the proteome file ( upid_gca_new ) .
"""
    Compares two upid_gca files from different Uniprot proteome releases
    and dumps the new upids in a new upid_gca file all resulting from the
    newer version of the proteome file (upid_gca_new). To be used for
    downloading a subset of genomes.

    upid_gca_out: A valid upid_gca file in .tsv format of an older reference
    proteome release
    upid_gca_new: A valid upid_gca file in .tsv format of a newer reference
        proteome release
    dest_dir: The path to a destination directory. Uses the directory of
    upid_gca_new if dest_dir is None

    returns: void
    """ # open and load the accessions to a dictionary # load old accessions # loop over new upids # if no destination directory provided, use directory of upid_gca_new # check if upid in the old release
upid_gca_old
upid_gca_new
dest_dir