次のsnakefileのように、snakemakeルールのRスクリプトのリストをループしようとしましたが、エラーが発生しました。
from snakemake.utils import R
rule test:
run:
R("""
print("hello!")
a = c(1, 2, 3)
for (i in a)
{
print(i)
}
""")
ここにエラーがあります。
RuleException:
NameError in line 12 of Snakefile:
The name '\n print(i)\n' is unknown in this context. Please make sure that you defined that variable. Also note that braces not used for variable access have to be escaped by repeating them, i.e. {{print $1}}
File "Snakefile", line 12, in __rule_test
File "~/miniconda/envs/py36/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Exiting because a job execution failed. Look above for error message
Shutting down, this might take some time.
Rで直接実行しても、コードにエラーはありませんでした。何が問題なのか、誰か考えがありますか?ありがとう。
{
そして、}
さえで、snakemakeで変数を呼び出すために使用されているrun
コマンド。
あなたはそれらを逃れるためにそれらを2倍にする必要があります。
エラーメッセージは参考情報です。
名前 '\ n print(i)\ n'は、このコンテキストでは不明です。その変数を定義したことを確認してください。また、変数アクセスに使用されていない中括弧は、それらを繰り返すことによってエスケープする必要があることに注意してください。つまり、{{print $ 1}}
したがって、コードは次のようになります。
from snakemake.utils import R
rule test:
run:
R("""
print("hello!")
a = c(1, 2, 3)
for (i in a)
{{
print(i)
}}
""")
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加