Isabella136 / AmrPlusPlus_SNP

GNU General Public License v3.0
1 stars 1 forks source link

Syntax error #26

Closed gustavogregoracci closed 1 year ago

gustavogregoracci commented 1 year ago

I've followed the installation guide and apparently everything is ok. I've installed pysam in a separate environment with pandas, upgraded both. I've cloned the gh repo as instructed. But the verification step is failing. Any ideas?

(env_nf) microbiologia@microbiologia:~/AmrPlusPlus_SNP$ pip freeze Cython==0.29.34 numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1649806299270/work pandas==1.3.5 pysam==0.21.0 python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1680088766131/work six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work

(env_nf) microbiologia@microbiologia:~/AmrPlusPlus_SNP$ python3 SNP_Verification.py File "SNP_Verification.py", line 275 with (open(config['FULL_FILE_NAMES']['NTYPE_OUTPUT'], "w") as outputN, ^ SyntaxError: invalid syntax

Isabella136 commented 1 year ago

This particular with statement uses syntax that was introduced in Python 3.9, so I'm guessing that you are using an earlier version

gustavogregoracci commented 1 year ago

Indeed. For the pysam installation, the compatible version installed by conda was 3.7.12. The environment was created around pysam. If I update for python 3.9, pysam is not recognized. Is there a way to reconcile python 3.9+ with pysam to fulfill dependencies for Amr++SNP?

Isabella136 commented 1 year ago

So I just checked and pysam 0.21.0 should be compatible with python 3.6 to 3.11 and cython 0.29.34 is compatible with all python 3 versions. The problem actually comes from pandas 1.3.5, which is compatible up to python 3.7. Updating pandas to 1.4.0 should fix this since it is compatible with python 3.8 and higher.

gustavogregoracci commented 1 year ago

Well, these suggestions did solve the syntax error. I had to install additionally biopython to run. But still there is another error in the test script. :/

(env_nf) microbiologia@microbiologia:~/AmrPlusPlus_SNP$ python -V Python 3.10.8 (env_nf) microbiologia@microbiologia:~/AmrPlusPlus_SNP$ pip freeze biopython @ file:///home/conda/feedstock_root/build_artifacts/biopython_1676639050243/work Cython @ file:///home/conda/feedstock_root/build_artifacts/cython_1680712295460/work numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1682210193659/work pandas==1.4.0 pysam==0.21.0 python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1680088766131/work six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work (env_nf) microbiologia@microbiologia:~/AmrPlusPlus_SNP$ python3 SNP_Verification.py [E::hts_open_format] Failed to open file "test/insertion_deletion3.bam" : No such file or directory Traceback (most recent call last): File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 349, in main() File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 341, in main results = process_genes(config, argList, gene_dict) File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 240, in process_genes pysam.sort("-o", config['TEMP_FILES']['TEMP_BAM_SORTED'], config['SOURCE_FILES']['BAM_INPUT']) File "/home/microbiologia/miniconda3/envs/env_nf/lib/python3.10/site-packages/pysam/utils.py", line 83, in call raise SamtoolsError( pysam.utils.SamtoolsError: 'samtools returned with error 1: stdout=, stderr=samtools sort: can\'t open "test/insertion_deletion3.bam": No such file or directory\n'

Isabella136 commented 1 year ago

Sorry for the delay; I've just finished my undergraduate studies and I also had to move out of my apartment.

I'm guessing you're simply testing the program to see if it was properly installed, and therefore you didn't specify the input file or the output directory as arguments. If that is the case, then the error comes from the config.ini file since it referenced testing files that were subsequently deleted. I just committed an update to the config.ini file so that it references the correct testing files, so it should no longer give out an error.

gustavogregoracci commented 1 year ago

So... we tried running our own file and a test file within the data folder. Both provide this error:

$ python3 SNP_Verification.py -i /home/microbiologia/AmrPlusPlus_SNP/align23-05_L1_Vs_MEGARES.sam Traceback (most recent call last): File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 349, in main() File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 338, in main config, argList = parse_config() File "/home/microbiologia/AmrPlusPlus_SNP/SNP_Verification.py", line 106, in parse_config config.read(configFile) File "/home/microbiologia/miniconda3/envs/env_nf/lib/python3.10/configparser.py", line 698, in read self._read(fp, filename) File "/home/microbiologia/miniconda3/envs/env_nf/lib/python3.10/configparser.py", line 1086, in _read raise MissingSectionHeaderError(fpname, lineno, line) configparser.MissingSectionHeaderError: File contains no section headers. file: 'config.ini', line: 7 '<!DOCTYPE html>\n'

We've aligned against Megares v3, so we supposedly have the section headers. You test.bam also have similarly formatted headers. Any ideas?

Thanks for the help!

Isabella136 commented 1 year ago

So the error come from the config file for some reason. I don't get this error in my end which means that the config file must have gotten modified on your end. I would advise double-checking it to make sure that there is no extra new lines. Additionally, you can also attach the current version of your config file in your next comment so that I can double check it

gustavogregoracci commented 1 year ago

I haven't altered the config.ini. You may find it attached. Thanks a lot!

config.zip

Isabella136 commented 1 year ago

So for some reason, the config file wasn't cloned properly since it contains html code. To make this easier, can you go ahead and download the file separately (I've attached it below)? Also, just before you replace the config file, can you go to the AmrPlusPlus_SNP directory and do a git status? config.zip

gustavogregoracci commented 1 year ago

That was it! Thank you!