Mercurial > repos > bimib > cobraxy
comparison COBRAxy/utils/model_utils.py @ 444:06564187fba3 draft
Uploaded
author | francesco_lapi |
---|---|
date | Thu, 11 Sep 2025 09:03:10 +0000 |
parents | f49c951c9fe6 |
children | f8b1761eee37 |
comparison
equal
deleted
inserted
replaced
443:3d4e10546917 | 444:06564187fba3 |
---|---|
442 return -1 | 442 return -1 |
443 rename_genes(model2,dict_genes) | 443 rename_genes(model2,dict_genes) |
444 | 444 |
445 return model2 | 445 return model2 |
446 | 446 |
447 | |
448 | |
449 # ---------- Utility helpers ---------- | 447 # ---------- Utility helpers ---------- |
450 def _normalize_colname(col: str) -> str: | 448 def _normalize_colname(col: str) -> str: |
451 return col.strip().lower().replace(' ', '_') | 449 return col.strip().lower().replace(' ', '_') |
452 | 450 |
453 def _choose_columns(mapping_df: 'pd.DataFrame') -> Dict[str, str]: | 451 def _choose_columns(mapping_df: 'pd.DataFrame') -> Dict[str, str]: |
459 chosen = {} | 457 chosen = {} |
460 # possibili nomi per ciascuna categoria | 458 # possibili nomi per ciascuna categoria |
461 candidates = { | 459 candidates = { |
462 'ensg': ['ensg', 'ensembl_gene_id', 'ensembl'], | 460 'ensg': ['ensg', 'ensembl_gene_id', 'ensembl'], |
463 'hgnc_id': ['hgnc_id', 'hgnc', 'hgnc:'], | 461 'hgnc_id': ['hgnc_id', 'hgnc', 'hgnc:'], |
464 'hgnc_symbol': ['hgnc_symbol', 'hgnc_symbol', 'symbol'], | 462 'hgnc_symbol': ['hgnc_symbol', 'hgnc symbol', 'symbol'], |
465 'entrez_id': ['entrez', 'entrez_id', 'entrezgene'] | 463 'entrez_id': ['entrez', 'entrez_id', 'entrezgene'] |
466 } | 464 } |
467 for key, names in candidates.items(): | 465 for key, names in candidates.items(): |
468 for n in names: | 466 for n in names: |
469 if n in cols: | 467 if n in cols: |