monarch-initiative / genophenocorr

Genotype Phenotype Correlation
https://monarch-initiative.github.io/genophenocorr/stable
MIT License
4 stars 1 forks source link

Provide documentation for key methods #142

Open pnrobinson opened 3 months ago

pnrobinson commented 3 months ago

Hi @lnrekerle @ielis

It would be really helpful to have documentation for all non-trivial methods. I am trying to hunt down the cause of the probable bug noted here, and I am getting to this and it would be helpful to have some explanation of what the two grouping predicates are and why the method returns None if both are false (why not have a third grouping predicate? How is other code expected to use this). Not having this kind of documentation makes it hard for others to work on the code, and it will make it hard for us to go back to it after a year or two. Please @lnrekerle add documentation for methods like this as you go through. If it is unclear then ask @ielis.

 def test(self, patient: Patient) -> typing.Optional[PatientCategory]:
        self._check_patient(patient)

        if len(patient.variants) == 0:
            return None

        results = [False, False]
        for variant in patient.variants:
            for ann in variant.tx_annotations:
                if ann.transcript_id == self._tx_id:
                    for var_eff in ann.variant_effects:
                        if var_eff == self._effect1:
                            results[0] = True
                        if var_eff == self._effect2:
                            results[1] = True
        if results == [True, False]:
            return GroupingPredicate.FIRST
        elif results == [False, True]:
            return GroupingPredicate.SECOND
        else:
            return None