How to use swiss army knife with batch file?
Hello guys,
?
I try to run the swiss army knife with batch files, but it gave me some error. Here is my commands and the error.
?
Command
(WGS) xueming@RNA:~/CHIP$ dx generate_batch_inputs --path "${projectid}:/Bulk/Exome sequences/Exome OQFE CRAM files/10/" -iin="(.*)_23143_0_0.cram$"
Found 9332 valid batch IDs matching desired pattern.
Created batch file dx_batch.0000.tsv
Created batch file dx_batch.0001.tsv
Created batch file dx_batch.0002.tsv
Created batch file dx_batch.0003.tsv
Created batch file dx_batch.0004.tsv
Created batch file dx_batch.0005.tsv
Created batch file dx_batch.0006.tsv
Created batch file dx_batch.0007.tsv
Created batch file dx_batch.0008.tsv
Created batch file dx_batch.0009.tsv
Created batch file dx_batch.0010.tsv
Created batch file dx_batch.0011.tsv
Created batch file dx_batch.0012.tsv
Created batch file dx_batch.0013.tsv
Created batch file dx_batch.0014.tsv
Created batch file dx_batch.0015.tsv
Created batch file dx_batch.0016.tsv
Created batch file dx_batch.0017.tsv
Created batch file dx_batch.0018.tsv
(WGS) xueming@RNA:~/CHIP$ head -n 3 dx_batch.0000.tsv > dx_example.tsv
(WGS) xueming@RNA:~$ dx run swiss-army-knife --batch-tsv dx_example.tsv -icmd='samtools view -T "/mnt/project/Bulk/Exome sequences/Exome OQFE CRAM files/helper_files/GRCh38_full_analysis_set_plus_decoy_hla.fa" -L "/mnt/project/CH_yao/gene.bed" -o "$in_prefix".bam "$in_name" ' -y --brief --priority normal --instance-type mem1_ssd1_v2_x2 --destination "${projectid}:/CH_yao/" --detach --tag "map"
?
Error
Traceback (most recent call last):
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/utils/batch_utils.py", line 112, in _type_convert
return _type_convert_array(val, klass)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/utils/batch_utils.py", line 98, in _type_convert_array
raise Exception("Malformed array {}".format(val))
Exception: Malformed array ${projectid}:file-G2Y0800JykJz1gjX3J7FvKXX
?
During handling of the above exception, another exception occurred:
?
Traceback (most recent call last):
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/scripts/dx.py", line 6133, in main
args.func(args)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/scripts/dx.py", line 3522, in run
run_body(args, handler, dest_proj, dest_path)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/scripts/dx.py", line 3134, in run_body
run_batch_all_steps(args, executable, dest_proj, dest_path, input_json, run_kwargs)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/scripts/dx.py", line 2982, in run_batch_all_steps
b_args = batch_launch_args(executable, input_json, args.batch_tsv)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/utils/batch_utils.py", line 182, in batch_launch_args
val_w_correct_type, ref_files = _type_convert(val.strip(), klass)
File "/i/melanoma_WGS/anaconda3/envs/WGS/lib/python3.10/site-packages/dxpy/utils/batch_utils.py", line 117, in _type_convert
raise Exception("value={} cannot be converted into class {}".format(val, klass))
Exception: value=${projectid}:file-G2Y0800JykJz1gjX3J7FvKXX cannot be converted into class array:file
?
I replace the subject id with ?${projectid}?? for safety.
?
I have test the command using one file name rather than batch file and it goes well. I think it maybe the problem of dx-tools, but I do not know how to solve it.
?
So, can anyone give me some suggestions? Thanks!
?
Sincerely,
Xueming? Yao
Comments
2 comments
The error message "Malformed array - cannot be converted into class array:file" indicated the inputs was not formatted properly.
After the .tsv file is generated, you will need to run a command similar to the following to encompass all file IDs with the square brackets. Please adjust the target column number(s) to meet your needs. The following example put the brackets on column #4 and #5.
head -n 1 dx_batch.0000.tsv > temp.tsv && tail -n +2 dx_batch.0000.tsv | awk '{sub($4, "[&]"); print}' | awk '{sub($5, "[&]"); print}' >> temp.tsv; tr -d '\r' < temp.tsv > new.tsv; rm temp.tsv
This is a part of the standard procedure that was included in the documentation:
https://documentation.dnanexus.com/user/running-apps-and-workflows/running-batch-jobs#generate-batch-file
Thank you! I run the similar command you? mentioned, it worked.
Please sign in to leave a comment.