PoonLab / Poplars

Open-source implementations of popular tools from Los Alamos National Laboratory HIV Database
GNU Affero General Public License v3.0
0 stars 0 forks source link

make /bin directory for open-source binary dependencies #5

Closed ArtPoon closed 5 years ago

ArtPoon commented 5 years ago
ArtPoon commented 5 years ago

Update setup.py script for Windows and macOS MAFFT binaries. @kwade4 has MAFFT wrapper script, need to push to repo.

kwade4 commented 5 years ago

setup.py and mafft.py (the MAFFT wrapper script) work for me on Linux , Windows, and macOS.

kwade4 commented 5 years ago

Testing mafft.py using a temp file resulted in a CalledProcessError because the temp file could not be opened.

https://github.com/PoonLab/Poplars/blob/260af1e558200ab21cfee5d7e6f409dc79b17118/poplars/mafft.py#L41

Setting shell=True in line 41, appears to fix this.

ArtPoon commented 5 years ago

We should avoid using shell=True. Can you please post the error?

kwade4 commented 5 years ago

This is my error:

Cannot open ~/PycharmProjects/Poplars/poplars/siv-test.fasta.

subprocess.CalledProcessError: Command '['/home/kwade4/PycharmProjects/Poplars/poplars/bin/mafft-linux64/mafft.bat', '--quiet', '~/PycharmProjects/Poplars/poplars/siv-test.fasta']' returned non-zero exit status 1.

Running all-in-one MAFFT (from poplars/bin) in the terminal using full absolute paths works.

ArtPoon commented 5 years ago

What happens if you manually run that Command from the command line?
Could there be a file permissions problem?

kwade4 commented 5 years ago

The Command works in the command line. I set read and write access for the test files, but it doesn't seem to work when I use a temp file.

ArtPoon commented 5 years ago

What do you mean by temp file? Can you elaborate? Is it a file stored at /tmp?

kwade4 commented 5 years ago

Yes, I am sorry for being unclear.

In sequence_locator.py, I create a temporary file (stored at /tmp using the tempfile module) that contains a query sequence and a reference sequence, and that the path to that file is passed to run_mafft in mafft.py.

I realized the error message I posted previously was for a test, where I manually created the query file (in my local repo) and passed it to run_mafft in mafft.py.

The same error arises with both cases.

ArtPoon commented 5 years ago

Check that the file created by tempfile still exists by the time you call the subprocess - the file gets destroyed as soon as the associated file stream is closed.

ArtPoon commented 5 years ago

https://stackoverflow.com/questions/94153/how-do-i-persist-to-disk-a-temporary-file-using-python

kwade4 commented 5 years ago

I figured it out (e07127c )- the mafft.py was correct after all (with the exception of a typo)

Adding a os.path.abspath call, rather than ~ fixed the error with the file in my local repo.

For the temporary file, I realized my problem was a simple indentation error. I had misaligned the run_mafft function call with the with tempfile.NamedTemporaryFile(...) block.

Thank you for all of your help!