Closed SRodenburg closed 7 years ago
Dear Users,
thanks a lot for your interest in ploidyNGS.
Unfortunately I have not been able to reproduce the error you reported.
pysam.AlingmentFile can either receive a file or an object. See (http://pysam.readthedocs.io/en/latest/api.html):
class pysam.AlignmentFile AlignmentFile(filepath_or_object, mode=None, template=None, reference_names=None, reference_lengths=None, text=NULL, header=None, add_sq_text=False, check_header=True, check_sq=True, reference_filename=None, filename=None, duplicate_filehandle=True)
Which version of pysam and of python are you using?
Thanks, Diego
Indeed, according to the documentation it seems to accept a string or a filehandle. I am using pysam 0.10.0 from inside the virtualenv as described in the installation docs of ploidyNGS. For now it doesn't complain.
Regards, Sander Rodenburg
Dear Sander,
I am not sure I understood correctly.
With pysam 0.10.0 it does not complain? Does it generate the PDF and tab files?
Diego
It does, but only after I change the code as described above. I don't understand why it doesn't work when pysam get a file handle instead of a filename string. Anyway, it correctly generates the pdf and table now.
Regards, Sander
I have the same problem as @SRodenburg , and his solution (with the addition of commenting out the line with bamOBJ.close()
) works for me.
Thanks for your comments. Yes, this is related to pysam 0.10, it should accept an object as per their documentation. I have updated the code so that the name of the BAM file passes directly as bamOBJ. I am closing this issue.
When I'm trying out either the test or one of my own files, I'm getting the following error:
I pinpointed the mistake to be in ploidyNGS.py, at line 59 There the BAM file is opened, while at line 85 the file handle is parsed to pysam. This should be the file name as a string only. To solve I simply changed line 59;
bamOBJ = open(args.bam,"r")
tobamOBJ = args.bam
The solution seems trivial, but it's not reflected in the traceback