Using "snakemake --config" to pass flags to a command - snakemake

I have read the Snakemake tutorial and it is clear to me how to use "snakemake --config ..." to modify parameters, and these get passed to the command being executed. Can I use "--config" to pass a flag to a command? For example, can I write a Snakefile that will execute either of these commands, based on using "--config"?
muscle -in unaligned.fa -out aligned.fa
muscle -in unaligned.fa -out aligned.fa -msf

Yes, from within a shell command definition in Snakemake, you can directly access config:
rule a:
input: ...
output: ...
shell:
"muscle -in {input} -out {output} {config[muscle-params]}"
Given that you e.g. invoke snakemake --config muscle-params="-msf"
or (even better) have the key defined in your config file.

Related

running metabat2 with snakemake but not getting the bin files

I have been trying to run metabat2 with snakemake. I can run it but the output files in metabat2/ are missing. The checkM that works after it does use the data and can work I just cant find the files later. There should be files created with numbers but it is imposible to predict how many files will be created. Is there a way I can specify it to make sure that the files are created in that file?
rule all:
[f"metabat2/" for sample in samples],
[f"checkm/" for sample in samples]
rule metabat2:
input:
"input/consensus.fasta"
output:
directory("metabat2/")
conda:
"envs/metabat2.yaml"
shell:
"metabat2 -i {input} -o {output} -v"
rule checkM:
input:
"metabat2/"
output:
c = "bacteria/CheckM.txt",
d = directory("checkm/")
conda:
"envs/metabat2.yaml"
shell:
"checkm lineage_wf -f {output.c} -t 10 -x fa {input} {output.d}"
the normal code to run metabat2 would be
metabat2 -i path/to/consensus.fasta -o /outputdir/bin -v
this will create in outputdir files with bin.[number].fa
I can't tell what the problem is but I have a couple of suggestions...
[f"metabat2/" for sample in samples]: I doubt this will do what you expect as it will simply create a list with the string metabat2/ repeat len(samples) times. Maybe you want [f"metabat2/{sample}" for sample in samples]? The same for [f"checkm/" for sample in samples]
The samples variable is not used anywhere in the rules following all. I suspect somewhere it should be used and/or you should use something like output: directory("metabat2/{sample}")
Execute snakemake with -p option to see what commands are executed. It may be useful to post the stdout from it.

openssl command generates an empty .key file from .pfx file

When I try to generate a key from a pfx certificate file, it creates an empty file
openssl pkcs12 -in test.pfx -nocerts -out test.key -nodes
I executed the command on git bash, Windows server 2019. The command seems to run without stoping because I can't type.
Thanks

Error with OpenSSL commands when run as a part of CMake Build

I am trying to generate self signed certificates using openSSL as part of internal feature testing. The intention is to have new certs (short lived) generated for every round of testing.
For the build procedure I have added custom targets to my CMakeLists.txt like so:
add_custom_target(ca_rsa
COMMAND mkdir -p ${INSTALL_LOCATION}/security_context/ca/cert
COMMAND mkdir -p ${INSTALL_LOCATION}/security_context/ca/private
COMMAND ${OPENSSL} req -nodes -x509 -days 30 -text -sha256 -newkey
rsa:2048 -keyout ${INSTALL_LOCATION}/security_context/ca/private/rsa_key.pem
-out ${INSTALL_LOCATION}/security_context/ca/cert/rsa_cert.pem
-config ./openssl_rsa.cnf)
ca_rsa is added as a dependency for the target executable for the project.
When I run the build I get the following error :
/bin/sh: req not found
recipe for target ca_rsa failed
I tried running the command by itself and it works fine.
Edit:
${OPENSSL} is set as follows:
set(OPENSSL ${OPENSSL_INSTALL_LOCATION}/bin/openssl)

zaproxy - API scan - missing c in config

I run the following command: docker run -v /etc/hosts:/etc/hosts -v $(pwd):/zap/wrk:rw -t owasp/zap2docker-weekly zap-api-scan.py -t api.yaml -f openapi -r zap_report.html -config replacer.full_list\(0\).description=auth1 -config replacer.full_list\(0\).enabled=true -config replacer.full_list\(0\).matchtype=REQ_HEADER -config replacer.full_list\(0\).matchstr=X-XXXXX-APIkey -config replacer.full_list\(0\).regex=false -config replacer.full_list\(0\).replacement=123456789
But got the error:
Traceback (most recent call last):
File "/zap/zap-api-scan.py", line 539, in
File "/zap/zap-api-scan.py", line 246, in main
with open(base_dir + config_file) as f:
IOError: [Errno 2] No such file or directory: '/zap/wrk/onfig'
How is it possible?
The problem is in how you pass parameters to the python script. The python script parse the -config as -c onfig, and trying to read configuration from the file onfig. You should pass zap params using the following format: -z "-config aaa=bbb -config ccc=ddd"'

CouchDB SSL handshake error

I've installed CouchDB on the mac via Homebrew (yay homebrew!):
brew install couchdb
Then I've done a bunch of SSL setup steps (in a shell script) that are detailed in the official documentation: http://docs.couchdb.org/en/1.6.1/config/http.html -
#!/bin/sh
currDir=$(pwd)
mkdir couch_certs
cd couch_certs
openssl genrsa > privkey.pem
openssl req -new -x509 -key privkey.pem -out couchdb.pem -days 1095
chmod 600 privkey.pem couchdb.pem
perl -p -i -e "s#\[daemons\]#[daemons]\nhttpsd = {couch_httpd, start_link, [https]}#" /usr/local/etc/couchdb/default.ini
perl -p -i -e "s#\[ssl\]#[ssl]\ncert_file = ${currDir}/couchdb.pem#" /usr/local/etc/couchdb/default.ini
perl -p -i -e "s#\[ssl\]#[ssl]\nkey_file = ${currDir}/privkey.pem#" /usr/local/etc/couchdb/default.ini
Then (same terminal), I launch couch:
couchdb
In a different terminal I test that:
curl -k https://127.0.0.1:6984/
And get a failure:
curl: (35) Server aborted the SSL handshake
What am I doing wrong?
Note I can get the same error when doing the CouchDB install as an application (section 2.3.1 of http://docs.couchdb.org/en/stable/install/mac.html)
Edit: I think it is an Erlang SSL issue: http://bugs.erlang.org/browse/ERL-74
My root cause was an older version of openssl (the one that came with OS X 10.10.5). After a homebrew install of openssl, and the same key-gen sequence, it all works.