Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: get mitochondrial genes from genomepy for SCTK #847

Open
siebrenf opened this issue Apr 13, 2022 · 2 comments
Open

FR: get mitochondrial genes from genomepy for SCTK #847

siebrenf opened this issue Apr 13, 2022 · 2 comments
Labels
enhancement New feature or request stale Period of inactivity

Comments

@siebrenf
Copy link
Member

import genomepy

def mito_genes(annotation_path):
    ann = genomepy.annotation(annotation_path)
    gtf = ann.named_gtf
    
    # very quick, very dirty way to find the name for the mitochondrion.
    # could also try to read this from the assembly report, but that's also not perfect. 
    mt = gtf[gtf["seqname"].str.contains("chrM", case=False, regex=False)]["seqname"].unique()
    if len(mt) != 1:
        mt = gtf[gtf["seqname"].str.contains("MT", case=False, regex=False)]["seqname"].unique()
    if len(mt) != 1:
        mt = gtf[gtf["seqname"].str.contains("mito", case=False, regex=False)]["seqname"].unique()
    if len(mt) != 1:
        mt = gtf[gtf["seqname"].str.contains("m", case=False, regex=False)]["seqname"].unique()
    if len(mt) != 1:
        print("we tried...")
        return {}
    
    genes = set(gtf[gtf["seqname"] == mt[0]].index)
    return genes
@siebrenf siebrenf added the enhancement New feature or request label Apr 13, 2022
@Maarten-vd-Sande
Copy link
Member

Could be a regex? Only the "m" one is tricky 😄

@stale
Copy link

stale bot commented Jul 10, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

@stale stale bot added the stale Period of inactivity label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Period of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants