Edinburgh-Genome-Foundry / DnaChisel

:pencil2: A versatile DNA sequence optimizer
https://edinburgh-genome-foundry.github.io/DnaChisel/
MIT License
213 stars 38 forks source link

Report generation broken after geneblocks install #58

Closed GC-repeat closed 3 years ago

GC-repeat commented 3 years ago

Hello,

I have installed DnaChisel using the [reports] suffix to generate reports. When I run DnaChisel on a genbank file or on a random seq (readme example) I do get a report but in the "Report.pdf" file it tells me to "install Geneblocks to see a friendly plot of sequence edits here. (pip install geneblocks) ". However, if I do so when I run my script again the report is not generated and I get the following error :

Traceback (most recent call last):
File "test.py", line 26, in problem.optimize_with_report(target="report.zip") File "/usr/local/lib/python3.8/dist-packages/dnachisel/DnaOptimizationProblem/DnaOptimizationProblem.py", line 260, in optimize_with_report data = write_optimization_report( File "/usr/local/lib/python3.8/dist-packages/dnachisel/reports/optimization_reports.py", line 366, in write_optimization_report diffs_ax = plot_optimization_changes(problem) File "/usr/local/lib/python3.8/dist-packages/dnachisel/reports/optimization_reports.py", line 277, in plot_optimization_changes diffs = DiffBlocks.from_sequences(sequence_before, sequence_after) File "/usr/local/lib/python3.8/dist-packages/geneblocks/DiffBlocks/DiffBlocks.py", line 79, in from_sequences common_blocks = CommonBlocks.from_sequences( File "/usr/local/lib/python3.8/dist-packages/geneblocks/CommonBlocks/CommonBlocks.py", line 56, in from_sequences homologies_dict = find_homologies_between_sequences( File "/usr/local/lib/python3.8/dist-packages/geneblocks/CommonBlocks/commonblocks_tools.py", line 133, in find_homologies_between_sequences proc = subprocess.Popen( File "/usr/lib/python3.8/subprocess.py", line 854, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'blastn'

veghp commented 3 years ago

hi, geneblocks requires a few dependencies, such as the blastn mentioned in the error. Please install them: https://github.com/Edinburgh-Genome-Foundry/geneblocks#installation

and let us know if it works. Then I can add a note in the readme to bring attention to this requirement.

GC-repeat commented 3 years ago

Thank you for the quick reply. After installing ncbi-blast+, the missingblastnerror disappeared and a report is generated but although the note to installgeneblocks` is gone the plot is absent. The output is the following :

===> SUCCESS - all constraints evaluations pass
✔PASS ┍ AvoidPattern0-507
│ Passed. Pattern not found ! ✔PASS ┍ EnforceTranslation[0-507(+)] │ Enforced by nucleotides restrictions

===> TOTAL OBJECTIVES SCORE: 0 ✔ 0 ┍ MaximizeCAI0-507 │ Codon opt. on window 0-507 scored -0.00E+00

Solving constraints Now optimizing the sequence
Success! Generating report.
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'

The plot is correctly generated using the web app with the same genbank file.

Note : I had to do sudo pip install geneblocks instead of pip install geneblocks as noted in the report before geneblocks installation.

Thank you.

veghp commented 3 years ago

sudo runs a command with root (superuser) privileges, from which I infer it uses the operating system's Python. This is not recommended for your own packages and work, instead use separate user installations. A few pointers are described at How to install and use EGF packages.

Running the command as root may also be the cause of your issue (see this discussion). Did you run with sudo / as root? Try running the command as a normal user. Also, do you use a local machine, or a remote server with no display / window system installed?

GC-repeat commented 3 years ago

Thank you for the links. It's working now, below is what I've done.

I'm using a local machine with Ubuntu 20.10 and python 3.8.6. I was indeed running things with sudo because it wasn't finding dnachisel, because I installed it using sudo pip install dnachisel[reports] as stated in the installation section here. Is sudo here accurate ? I also thought that I may have messed up with my anaconda installation so I uninstalled it and when I tried to run the script again. The report was still generated without the QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' error.

Next I reinstalled (properly) anaconda and followed the anaconda section on https://github.com/Edinburgh-Genome-Foundry/HowTo/tree/master/EGF to create the egf environment with python 3.6. Then I installed dnachisel and geneblocks in this environment by running pip install dnachisel[reports] and pip install geneblocks. Now, running the script in the egf environment generates the report with the plot.

I don't know if it's of any help but out of curiosity, I've created an environment with python=3.8, installed the packages the same way and ran the script. The generated report does not contain the plot.

Thank you for your help!

veghp commented 3 years ago

Yes installing the way you described seems correct. Maybe I'll remove sudo from the readme. Thanks, I'll keep the plot in mind for the planned testing of the packages for Python v3.8.