harrispopgen / mutyper

Ancestral k-mer mutation types for SNP data
https://harrispopgen.github.io/mutyper/
MIT License
7 stars 3 forks source link

Problem with ancestor command #20

Closed RenzoTale88 closed 3 years ago

RenzoTale88 commented 3 years ago

Hello, I'm trying to run the mutyper ancestor command using a genome and its ancestor generated from cactus multiple genome alignments. Specifically, I've generated the alignments using 9 different genomes, extracted the Ancestral sequence for the clade of interest in fasta file, and generated the chain file following the instructions (here)[https://github.com/ComparativeGenomicsToolkit/hal/blob/chaining-doc/doc/chaining-mapping.md]. I've then input the file to the mutyper ancestor command using a VCF file that I've generated on the genome of interest:

mutyper ancestor myvcf.snps.vcf.gz genome1.fasta Anc3.fasta Anc3ToGenome1.chain ancestral_genome1_mutyper

However, when I run it I get the following error:

Traceback (most recent call last):
  File "/path/to/myanaconda/mutyperenv/bin/mutyper", line 8, in <module>
    sys.exit(main())
  File "/path/to/myanaconda/mutyperenv/lib/python3.8/site-packages/mutyper/cli.py", line 333, in main
    args.func(args)
  File "/path/to/myanaconda/mutyperenv/lib/python3.8/site-packages/mutyper/cli.py", line 69, in ancestral_fasta
    anc[chrom][variant.start] = 'N'
UnboundLocalError: local variable 'chrom' referenced before assignment

Not sure what is the problem, am I inputting something wrong?

Thank you in advance Andrea

RenzoTale88 commented 3 years ago

So, adding a command:

        chrom=variant.CHROM

After line 60 of file cli.py fixed the issue

wsdewitt commented 3 years ago

Ah, thanks for this! It looks like chrom gets defined in the previous code block, but only if a bed callability mask is being used (which I always use, so hadn't hit this). Your fix looks correct to me, so I can implement it, or you can create a pull request if you'd prefer?

RenzoTale88 commented 3 years ago

Hi @WSDeWitt sorry for coming back this late, I don't mind if it is easier for you to implement the change?

RenzoTale88 commented 3 years ago

I've made a pull request implementing the fix described in a bit more consistent way with the syntax in the function.

wsdewitt commented 3 years ago

@RenzoTale88 Thanks for helping with this! The patch is now available on pypi (v0.5.4)

RenzoTale88 commented 3 years ago

@WSDeWitt glad to be of help!