scripts/export/rfam_xml_dumper.py
def build_additional_fields(entry, fields, num_3d_structures, fam_ncbi_ids, entry_type, tax_strings=None):
    """
    This function expands the entry xml field with the additional fields

    entry:  This is the xml.etree.ElementTree at the point of entry
    fields: A list of additional fields to expand the entry with
    """

    add_fields = ET.SubElement(entry, "additional_fields")

    # adding entry type
    ET.SubElement(add_fields, "field", name="entry_type").text = entry_type

    # adding authors
    authors = fields["author"]
    authors = authors.replace(';', ',')
    author_list = get_value_list(authors, rs.AUTH_DEL)

    for author in author_list:
        ET.SubElement(add_fields, "field", name="author").text = author

    if entry_type == "Family":

        # number of species
        ET.SubElement(add_fields, "field", name="num_species").text = str(fields["num_species"])
        # number of 3D structures
        ET.SubElement(
            add_fields, "field", name="num_3d_structures").text = str(num_3d_structures)
        # num seed
        ET.SubElement(add_fields, "field", name="num_seed").text = str(fields["num_seed"])
        # num full
        ET.SubElement(add_fields, "field", name="num_full").text = str(fields["num_full"])

        # rna types
        rna_types = get_value_list(fields["rna_type"], rs.RNA_TYPE_DEL)

        for rna_type in rna_types:
            ET.SubElement(add_fields, "field", name="rna_type").text = rna_type

        # has 3d structure
        if num_3d_structures > 0:
            ET.SubElement(
                add_fields, "field", name="has_3d_structure").text = "Yes"
        else:
            ET.SubElement(
                add_fields, "field", name="has_3d_structure").text = "No"

        # add popular species if any
        for species in rs.POPULAR_SPECIES:
            if species in fam_ncbi_ids:
                ET.SubElement(
                    add_fields, "field", name="popular_species").text = str(species)

        for tax_string in tax_strings:
            ET.SubElement(add_fields, "field", name="tax_string").text = str(tax_string)


        # work on pseudoknots here
        if fields["has_pseudoknot"] == 1:
            pseudoknots = fields["pseudoknots"]

            ET.SubElement(add_fields, "field", name="has_pseudoknot").text = "Yes"

            for pk_evidence in pseudoknots:
                ET.SubElement(add_fields, "field", name="pseudoknot_evidence").text = pk_evidence
        else:
            ET.SubElement(add_fields, "field", name="has_pseudoknot").text = "No"

            # build hierarchical_fields tree here...

    # perhaps move this to clan and motif xml builder
    else:
        num_families = None

        if entry_type == "Motif":
            num_families = fetch_value(
                rs.NUM_FAMS_MOTIF, fields["id"])

        elif entry_type == "Clan":
            num_families = fields["num_families"]

        ET.SubElement(add_fields, "field", name="num_families").text = str(
            num_families)

    # returning node
    return add_fields

    This function expands the entry xml field with the additional fields

    entry:  This is the xml.etree.ElementTree at the point of entry
    fields: A list of additional fields to expand the entry with
    
This function expands the entry xml field with the additional fields
entry:  This is the xml.etree.ElementTree at the point of entry
fields: A list of additional fields to expand the entry with
This function expands the entry xml field with the additional fields entry : This is the xml . etree . ElementTree at the point of entry fields : A list of additional fields to expand the entry with
def build_additional_fields(entry, fields, num_3d_structures, fam_ncbi_ids, entry_type, tax_strings=None):
    add_fields = ET.SubElement(entry, "additional_fields")
    ET.SubElement(add_fields, "field", name="entry_type").text = entry_type
    authors = fields["author"]
    authors = authors.replace(';', ',')
    author_list = get_value_list(authors, rs.AUTH_DEL)
    for author in author_list:
        ET.SubElement(add_fields, "field", name="author").text = author
    if entry_type == "Family":
        ET.SubElement(add_fields, "field", name="num_species").text = str(fields["num_species"])
        ET.SubElement(
            add_fields, "field", name="num_3d_structures").text = str(num_3d_structures)
        ET.SubElement(add_fields, "field", name="num_seed").text = str(fields["num_seed"])
        ET.SubElement(add_fields, "field", name="num_full").text = str(fields["num_full"])
        rna_types = get_value_list(fields["rna_type"], rs.RNA_TYPE_DEL)
        for rna_type in rna_types:
            ET.SubElement(add_fields, "field", name="rna_type").text = rna_type
        if num_3d_structures > 0:
            ET.SubElement(
                add_fields, "field", name="has_3d_structure").text = "Yes"
        else:
            ET.SubElement(
                add_fields, "field", name="has_3d_structure").text = "No"
        for species in rs.POPULAR_SPECIES:
            if species in fam_ncbi_ids:
                ET.SubElement(
                    add_fields, "field", name="popular_species").text = str(species)
        for tax_string in tax_strings:
            ET.SubElement(add_fields, "field", name="tax_string").text = str(tax_string)
        if fields["has_pseudoknot"] == 1:
            pseudoknots = fields["pseudoknots"]
            ET.SubElement(add_fields, "field", name="has_pseudoknot").text = "Yes"
            for pk_evidence in pseudoknots:
                ET.SubElement(add_fields, "field", name="pseudoknot_evidence").text = pk_evidence
        else:
            ET.SubElement(add_fields, "field", name="has_pseudoknot").text = "No"
    else:
        num_families = None
        if entry_type == "Motif":
            num_families = fetch_value(
                rs.NUM_FAMS_MOTIF, fields["id"])
        elif entry_type == "Clan":
            num_families = fields["num_families"]
        ET.SubElement(add_fields, "field", name="num_families").text = str(
            num_families)
    return add_fields
def build_additional_fields ( entry , fields , num_3d_structures , fam_ncbi_ids , entry_type , tax_strings = None ) : add_fields = ET . SubElement ( entry , "additional_fields" ) ET . SubElement ( add_fields , "field" , name = "entry_type" ) . text = entry_type authors = fields [ "author" ] authors = authors . replace ( ';' , ',' ) author_list = get_value_list ( authors , rs . AUTH_DEL ) for author in author_list : ET . SubElement ( add_fields , "field" , name = "author" ) . text = author if entry_type == "Family" : ET . SubElement ( add_fields , "field" , name = "num_species" ) . text = str ( fields [ "num_species" ] ) ET . SubElement ( add_fields , "field" , name = "num_3d_structures" ) . text = str ( num_3d_structures ) ET . SubElement ( add_fields , "field" , name = "num_seed" ) . text = str ( fields [ "num_seed" ] ) ET . SubElement ( add_fields , "field" , name = "num_full" ) . text = str ( fields [ "num_full" ] ) rna_types = get_value_list ( fields [ "rna_type" ] , rs . RNA_TYPE_DEL ) for rna_type in rna_types : ET . SubElement ( add_fields , "field" , name = "rna_type" ) . text = rna_type if num_3d_structures > 0 : ET . SubElement ( add_fields , "field" , name = "has_3d_structure" ) . text = "Yes" else : ET . SubElement ( add_fields , "field" , name = "has_3d_structure" ) . text = "No" for species in rs . POPULAR_SPECIES : if species in fam_ncbi_ids : ET . SubElement ( add_fields , "field" , name = "popular_species" ) . text = str ( species ) for tax_string in tax_strings : ET . SubElement ( add_fields , "field" , name = "tax_string" ) . text = str ( tax_string ) if fields [ "has_pseudoknot" ] == 1 : pseudoknots = fields [ "pseudoknots" ] ET . SubElement ( add_fields , "field" , name = "has_pseudoknot" ) . text = "Yes" for pk_evidence in pseudoknots : ET . SubElement ( add_fields , "field" , name = "pseudoknot_evidence" ) . text = pk_evidence else : ET . SubElement ( add_fields , "field" , name = "has_pseudoknot" ) . text = "No" else : num_families = None if entry_type == "Motif" : num_families = fetch_value ( rs . NUM_FAMS_MOTIF , fields [ "id" ] ) elif entry_type == "Clan" : num_families = fields [ "num_families" ] ET . SubElement ( add_fields , "field" , name = "num_families" ) . text = str ( num_families ) return add_fields
This function expands the entry xml field with the additional fields
entry:  This is the xml.etree.ElementTree at the point of entry
fields: A list of additional fields to expand the entry with
This function expands the entry xml field with the additional fields entry : This is the xml . etree . ElementTree at the point of entry fields : A list of additional fields to expand the entry with
"""
    This function expands the entry xml field with the additional fields

    entry:  This is the xml.etree.ElementTree at the point of entry
    fields: A list of additional fields to expand the entry with
    """ # adding entry type # adding authors # number of species # number of 3D structures # num seed # num full # rna types # has 3d structure # add popular species if any # work on pseudoknots here # build hierarchical_fields tree here... # perhaps move this to clan and motif xml builder # returning node
entry
fields
num_3d_structures
fam_ncbi_ids
entry_type
tax_strings