Qiime - pynest, call from shell_exec() in PHP not working
1
0
Entering edit mode
7.6 years ago
YOT ▴ 30

Hello folks,

I am running Qiime on a linux virtual Box 64Bts.

When I am on TERMINAL AND I run the command qiime@qiime-VirtualBox:~$pynest it works good. I can see the expected output. But when a call from php, echo shell_exec("pynest"); or echo shell_exec("pynest.py; echo$?"); or echo shell_exec("pynest; echo $?"); it not works. I should have the expected output. Instead I have the number 127. Is it a kind of "software not found"? How to solve this issue? thanks qiime php shell_exec • 4.2k views ADD COMMENT 0 Entering edit mode Is the location of the executable available from the PATH that the PHP module sees? Presumably not. ADD REPLY 0 Entering edit mode Dear Devon, thanks to take your time to reply my question. I've try to give to php the complete path but it not works as well. I've use system("/home/qiime/qiime_software/pynast-1.2.2-release/bin/pynast.py",$res); // echo 127 and
system("/home/qiime/qiime_software/pynast-1.2.2-release/bin/pynast",$res); // echo 1  I' ve try to call a bash script that calls the pynast but it not works. It can read the echo from bash "end of bash test" but can not run the python scrypt pynast. If I use this code $result = $output_including_status = shell_exec("/home/qiime/bioinfo/Steve/testSeq.sh 2>&1; echo$?");


I can see on the browser

line 4: parallel_align_seqs_pynast.py: command not found end of bash test 0


It semms to be one of the 2 reasons. 1-PHP is not reading python or 2- as you said, php is not recognizing the path of the pynast executable in python. Or both of them. i dont know how to set the module in php to see the executable on LAMP. Do you have any clue? Thanks Any information will be appreciated.

0
Entering edit mode

It's been a few years since I was coding in PHP and doing sys admin type things, so I don't have any quick suggestions there. You might post this on a PHP forum or maybe even stackoverflow (though they can be tougher to deal with).

0
Entering edit mode

Hi Devon thanks any way. Yes I found someone that had same problem as mine. He said he found a solution but it is not clear how he did that. http://stackoverflow.com/questions/11733149/i-need-to-run-a-python-script-from-php/11733888#11733888

0
Entering edit mode

It looks like the trick is just setting the environment variables within PHP to match those of the terminal (at least close enough that python knows where to look for things). It's been years since I've had to do that, but presumably that would solve things.

0
Entering edit mode
0
Entering edit mode

This might be obvious, but do you realise it's 'pynast', not 'pynest'. It's not just a simple typo is it?

Just covering all bases :-)

0
Entering edit mode

Hi Daniel, thanks for your note, but yes. It was an error when I was tapping the post. If you see the yellow lines on my reply for Devon when I used copy past the name is correct. Thanks

0
Entering edit mode
7.6 years ago
YOT ▴ 30

Hello folks,

I will post here a little solution that I found (so far) for this kind of issue.

1. We must to put the environment to the apache LAMP for the PHP session.
2. I used putenv() function, as suggested by Devon.
3. I am using qiime's virtual machine, so the path will be the same for those who are using the same machine.
4. Inside /home/qiime/qiime_software/activate.sh you will see the environment variables to run qiime's functions.
5. Inside this file, you will see for exemple, the first line like that: export QIIME_CONFIG_FP=/home/qiime/qiime_software/qiime-1.8.0-release/../qiime_config
6. Go to your code PHP put inside the putenv() function the yellow part of the above line. like this

$setting="QIIME_CONFIG_FP=/home/qiime/qiime_software/qiime-1.8.0-release/../qiime_config"; echo "1-".putenv($setting);

7. You should see 1-1 on the browser. That means, your "1-" variable was sitted.

8. If you want all the code here you are: just copy & paste

10. You can call for exemple "parallel_align_seqs_pynast" function like this

$result =$output_including_status = shell_exec("parallel_align_seqs_pynast.py -i ./ YOUR_SEQUENCE.fasta -o ./RESULT_DIRECTORY");
echo \$result;


Well, so far I think it works. I think this is the way you can implement a easy interface web for qiime users.

But I have this error

Traceback (most recent call last):
File "/home/qiime/qiime_software/qiime-1.8.0-release/bin/parallel_align_seqs_pynast.py", line 106, in main()
File "/home/qiime/qiime_software/qiime-1.8.0-release/bin/parallel_align_seqs_pynast.py", line 102, in main suppress_submit_jobs=False)
File "/home/qiime/qiime_software/qiime-1.8.0-release/lib/qiime/parallel/util.py", line 136, in __call__ self._precommand_initiation(input_fp,output_dir,working_dir,params)
File "/home/qiime/qiime_software/qiime-1.8.0-release/lib/qiime/parallel/align_seqs.py", line 29, in _precommand_initiation output_dir=get_qiime_temp_dir())
File "/home/qiime/qiime_software/pycogent-1.5.3-release/lib/python2.7/site-packages/cogent/app/formatdb.py", line 119, in build_blast_db_from_fasta_path app_result = fdb(fasta_path)
File "/home/qiime/qiime_software/pycogent-1.5.3-release/lib/python2.7/site-packages/cogent/app/util.py", line 251, in __call__ open(errfile).read())
cogent.app.util.ApplicationError: Unacceptable application exit status: 2
Command: cd "/tmp//"; formatdb -l "core_set_aligned.fasta.imputed.txt.log" -o T -n "core_set_aligned.fasta.imputed.txt" -i "./core_set_aligned.fasta.imputed.txt" -p F > "/dev/null" 2> "/dev/null" StdOut: StdErr: 1


What that means? It seems that some python functions is calling others and passing arguments but it is not working!!!

Any Idea?

thanks