cfe-lab / MiCall

Pipeline for processing FASTQ data from an Illumina MiSeq to genotype human RNA viruses like HIV and hepatitis C
https://cfe-lab.github.io/MiCall
GNU Affero General Public License v3.0
14 stars 9 forks source link

Get key positions from resistance rules #431

Open donkirkby opened 6 years ago

donkirkby commented 6 years ago

Since we added rules for scoring the resistance to HIV and HCV drugs, we could use the mutation positions to choose key positions when giving a coverage score. Presumably, we should continue to allow key positions as part of the project definitions for regions that don't have resistance rules.

Somewhat related to the tool for editing project definitions described in #425.

jeff-k commented 6 years ago

The AST could be crawled recursively to accumulate the mutations in DrmExpr nodes:

def crawl(term):
    if hasattr(term, 'mutations'):
         return term.mutations
    elif issubclass(type(term), DrmExpr):
        return [crawl(m) for m in term.children]

This could be a method of the DRMParser class.

The returned list would have to be flattened and cleaned of Nones returned by non-mutation terminal nodes. With a stricter class hierarchy that's rooted in the common drm module this could be cleaned up.