question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'Error in generated code:', file=sys.stderr

See original GitHub issue

Dear SALSA programmers,

I am trying to run SALSA in a bioconda-installed version. Specifically, I installed it as follows:

mamba create -n salsa2_2.3 salsa2=2.3 ;

I then prepared a sorted *.bed file and length file as instructed:

conda activate bedtools_2.30.0 ;
bamToBed -i $PROJECT/necator/Hi-C/2021.12.16/N_amer_2021.10.26.OmniC.dedup.mapped.PT.bam > N_amer_2021.10.26.OmniC.dedup.mapped.PT.orig.bed ;
sort -k 4 N_amer_2021.10.26.OmniC.dedup.mapped.PT.orig.bed > N_amer_2021.10.26.OmniC.dedup.mapped.PT.bed ;
conda deactivate ;

conda activate samtools_1.14 ;
samtools faidx N_amer_2021.10.26.fa ;
conda deactivate ;

Finally, I tried running SALSA:

conda activate salsa2_2.3 ;
run_pipeline.py \
--assembly N_amer_2021.10.26.fa \
--length N_amer_2021.10.26.fa.fai \
--bed N_amer_2021.10.26.OmniC.dedup.mapped.PT.bed \
--enzyme DNASE \
--output $PROJECT/necator/Hi-C/2021.12.27.01/salsa \
--cutoff 10000 \
--iter 3 \
--dup N_amer_2021.10.26.salsa_dups.txt \
--exp 234000000 --clean yes --prnt yes ;
conda deactivate ;

SALSA2 ran for a short while, but then hit the wall and died, with the following error messages:

bedfile loaded
Starting Iteration 1
bedfile started
bedfile loaded
Traceback (most recent call last):
  File "/ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/bin/fast_scaled_scores.py", line 2, in <module>
    import networkx as nx
  File "/ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/lib/python2.7/site-packages/networkx/__init__.py", line 68, in <module>
    import networkx.utils
  File "/ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/lib/python2.7/site-packages/networkx/utils/__init__.py", line 2, in <module>
    from networkx.utils.decorators import *
  File "/ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/lib/python2.7/site-packages/networkx/utils/decorators.py", line 7, in <module>
    from decorator import decorator
  File "/ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/lib/python2.7/site-packages/decorator.py", line 162
    print('Error in generated code:', file=sys.stderr)
                                          ^
SyntaxError: invalid syntax

python2 /ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/bin/RE_sites.py -a /ocean/projects/mcb190015p/schwarze/necator/Hi-C/2021.12.27.01/salsa/assembly.cleaned.fasta -e DNASE > /ocean/projects/mcb190015p/schwarze/necator/Hi-C/2021.12.27.01/salsa/re_counts_iteration_1
python2 /ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/bin/make_links.py -b /ocean/projects/mcb190015p/schwarze/necator/Hi-C/2021.12.27.01/salsa/alignment_iteration_1.bed -d /ocean/projects/mcb190015p/schwarze/necator/Hi-C/2021.12.27.01/salsa -i 1 -x N_amer_2021.10.26.salsa_dups.txt
python2 /ocean/projects/mcb190015p/schwarze/anaconda3/envs/salsa2_2.3/bin/fast_scaled_scores.py -d /ocean/projects/mcb190015p/schwarze/necator/Hi-C/2021.12.27.01/salsa -i 1

Why should a bioconda package for SALSA2 running in its own versioned environment have this problem? How should I fix it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SchwarzEMcommented, Dec 30, 2021

Thanks for the pointer about conflicting networkx versions. I have devised a method for using conda and pip to create an environment within which I have successfully run SALSA2. This may be useful to users who find conda to be a useful tool for managing versions of Python and other software. Here is what I did which worked:

mamba create -n salsa2_reqs python=2.7.14 ;
conda activate salsa2_reqs ;
pip install networkx==1.11 ; 

cd $PROJECT/src ;
git clone https://github.com/marbl/SALSA.git SALSA2 ;

cd $PROJECT/src/SALSA2 ;
make ;
mkdir bin ;
mv -i *.sh *.py break_contigs break_contigs_start correct_links bin ;
conda deactivate ;

[move to working directory, and run the following as a 1-CPU batch job:]

conda activate salsa2_reqs ;
PATH="$PROJECT/src/SALSA2/bin:$PATH" ;
export PATH ;
run_pipeline.py --assembly N_amer_2021.10.26.fa --length N_amer_2021.10.26.fa.fai \
--bed N_amer_2021.10.26.OmniC.dedup.mapped.PT.bed --enzyme DNASE --output $PROJECT/necator/Hi-C/2021.12.27.01/salsa \
--cutoff 10000 --dup N_amer_2021.10.26.salsa_dups.txt \
--exp 234000000 --clean yes --prnt yes ;
conda deactivate ;

… which worked! No crash at the networkx-invoking step; full run to near-chromosomal scaffolds.

I think the key step is using conda to create an invokable environment that has nothing but python 2.7, and then using pip to customize that environment by installing networkx 1.11 while actively in that environment, which will then be the sole active networkx version whenever that environment is reactivated. That works and allows SALSA2 to function; nothing else seems to.

0reactions
Surbhigrewalcommented, Aug 5, 2022

Thank you for this solution. Pip install networkx instead of conda install networkx in salsa environment solved the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IPython 'Error in generated code:', file=sys.stderr
Then when I tried the command ipython , I got the error print('Error in generated code:', file=sys.stderr) in line 162 of decorator.py ....
Read more >
file=sys.stderr syntax error · Issue #1 · arvestad/alv - GitHub
I installed alv using pip install alv, after successful installation I run alv and get: File "/usr/local/bin/alv", line 103 print('Alv ...
Read more >
Error message upgrading from 2.3.3 to 2.3.4 - Indico Community
hi, I tried to upgrade the 2.3.3 to latest version following instructions at: Upgrade — Indico 2.3.4 documentation but got following error messages:...
Read more >
FS#34302 : [ipython2] syntax error - Arch Linux
print('Error in generated code:', file=sys.stderr) ^ SyntaxError: invalid syntax. Additional info: * package versions: 2013-03-13
Read more >
exaile 3.4.5 shows file=sys.stderr error on ubuntu 16.04
I executed exaile command in terminal and it shows the below error. File "/usr/lib/python3.5/site.py", line 182 file=sys.stderr) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found