Skip to content
Snippets Groups Projects
Commit 3d00a27d authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Eleos special case

parent 4a92d484
Branches operon-struct-type operon-struct-type-article
No related tags found
No related merge requests found
Pipeline #131977 failed with stages
in 8 minutes and 32 seconds
...@@ -304,44 +304,82 @@ def system_operon_structure( ...@@ -304,44 +304,82 @@ def system_operon_structure(
in_exchangeables = False in_exchangeables = False
current_gene = {} current_gene = {}
exchangeables = [] exchangeables = []
with open(def_path["path"]) as file:
for event, elem in ET.iterparse(file, events=("start", "end")): # <model inter_gene_max_space="5" min_mandatory_genes_required="2" min_genes_required="2" vers="2.0">
if event == "start":
if ( # <gene name="Eleos__LeoA" presence="mandatory">
elem.tag == "gene" # <exchangeables>
and not in_exchangeables # <gene name="Eleos__LeoA2"/>
and elem.attrib["presence"] != "forbidden" # </exchangeables>
): # </gene>
current_gene = {
"system": system, # <gene name="Eleos__LeoBC" presence="mandatory"/>
"subsystem": subsystem,
"gene": elem.attrib["name"], # <gene name="Eleos__LeoB" presence="mandatory"/>
"version": def_path["version"],
"exchangeables": None, # <gene name="Eleos__LeoC" presence="mandatory"/>
}
# </model>
# get hmm definition to extract the size if system == 'Eleos':
base_path_list = def_path["path"].parts[0:-4] eleos_struct = [
profile_path = ( {
Path(*base_path_list) "system": system,
/ f"profiles/{current_gene['gene']}.hmm" "subsystem": "Eleos",
) "gene": "Eleos__LeoA",
with open(profile_path) as profile_file: "version": "1.2.4",
for line in profile_file: "exchangeables": "Eleos__LeoA2",
if line.startswith("LENG"): "size": 559,
size = int(re.split(r"\s+", line)[1]) },
current_gene["size"] = size {
system_genes.append(current_gene) "system": system,
if elem.tag == "gene" and in_exchangeables: "subsystem": "Eleos",
exchangeables.append(elem.attrib["name"]) "gene": "Eleos__LeoBC",
if elem.tag == "exchangeables": "version": "1.2.4",
in_exchangeables = True "exchangeables": None,
exchangeables = [] "size": 601,
elif event == "end": },
if elem.tag == "exchangeables":
in_exchangeables = False ]
current_gene["exchangeables"] = ",".join(exchangeables) system_genes += eleos_struct
exchangeables = [] else:
with open(def_path["path"]) as file:
for event, elem in ET.iterparse(file, events=("start", "end")):
if event == "start":
if (
elem.tag == "gene"
and not in_exchangeables
and elem.attrib["presence"] != "forbidden"
):
current_gene = {
"system": system,
"subsystem": subsystem,
"gene": elem.attrib["name"],
"version": def_path["version"],
"exchangeables": None,
}
# get hmm definition to extract the size
base_path_list = def_path["path"].parts[0:-4]
profile_path = (
Path(*base_path_list)
/ f"profiles/{current_gene['gene']}.hmm"
)
with open(profile_path) as profile_file:
for line in profile_file:
if line.startswith("LENG"):
size = int(re.split(r"\s+", line)[1])
current_gene["size"] = size
system_genes.append(current_gene)
if elem.tag == "gene" and in_exchangeables:
exchangeables.append(elem.attrib["name"])
if elem.tag == "exchangeables":
in_exchangeables = True
exchangeables = []
elif event == "end":
if elem.tag == "exchangeables":
in_exchangeables = False
current_gene["exchangeables"] = ",".join(exchangeables)
exchangeables = []
with open(output, "w") as f: with open(output, "w") as f:
fieldnames = [ fieldnames = [
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment