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

[CompareSTR] Typo in condition and redundant condition #146

Closed
Kulivox opened this issue Feb 2, 2022 · 1 comment
Closed

[CompareSTR] Typo in condition and redundant condition #146

Kulivox opened this issue Feb 2, 2022 · 1 comment

Comments

@Kulivox
Copy link
Contributor

Kulivox commented Feb 2, 2022

The condition on line 821 in this snippet contains a typo, variable 'is_min' should not be enclosed in brackets because it creates a nested list. 'all()' built in function evaluates to True on nested non empty lists, therefore, this condition will always evaluate to True. The second, nested condition on line 822 hides this bug, and is unnecessary, because contents of variable 'is_min' are based on information about positions and chrom. ids of the two records that are being compared.
https://github.com/gymreklab/TRTools/blob/eac7523a5eef740fe4eaa7aa9b51b3480eb59a60/trtools/compareSTR/compareSTR.py#L812-L831

Checks on previous lines ensure that is_min is always list of two bools.

Fix:

    while not done:
        if any([item is None for item in current_records]): break
        if args.numrecords is not None and num_records >= args.numrecords: break
        if args.verbose: mergeutils.DebugPrintRecordLocations(current_records, is_min)
        if mergeutils.CheckMin(is_min): return 1
        if all(is_min):
            UpdateComparisonResults(trh.HarmonizeRecord(vcftype1, current_records[0]), \
                                    trh.HarmonizeRecord(vcftype2, current_records[1]), \
                                    sample_idxs,
                                    args.ignore_phasing, args.period,
                                    format_fields, format_bins,
                                    args.stratify_file,
                                    overall_results, locus_results,
                                    sample_results, bubble_results)

This change doesn't break current tests

@LiterallyUniqueLogin
Copy link
Contributor

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants