Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

python - Snakemake: error when using split command?

I'm getting an error when I use the Unix split command in the shell part of my Snakemake rule:

rule split:
    input:
            "test_file.txt"
    output:
            directory("split_test_file")
    shell:
            '''
            mkdir {output}
            split -1 3 {input} split_
            mv split_* {output}
            '''

This is the error:

Error in rule split:
jobid: 0
output: split_test_file
shell:
    
    mkdir split_test_file
    split -1 3 test_file.txt split_
    mv split_* split_test_file
    
    (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

I think the error occurs in the mv split_* split_test_file line because when I run only the first 2 lines there is no error. I can't seem to find why I can't move all the files that resulted from splitting test_file.txt into the output directory? Thank you so much!

question from:https://stackoverflow.com/questions/65947348/snakemake-error-when-using-split-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. There is a typo in split command, where -1 needs to be letter -l.
  2. Your mv command would result in error mv: cannot move ‘split_test_file’ to a subdirectory of itself, ‘split_test_file/split_test_file’. Both the files to be moved and the destination directory begin with same string split_, which leads to this error. Modifying either of them would fix this issue.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...