簡體   English   中英

Python 腳本 output 修改與 bash 在 nextflow

[英]Python script output modification with bash in nextflow

我有一個 python 腳本 (make_chunk.py),它從輸入通道獲取輸入文件並打印 3 arrays。

import pandas as pd
import numpy as np
import os
import sys

data=sys.argv[1]
df=pd.read_csv(data,sep='\t',header=None)
chnk_ult=df[df.columns[3]].max()

chnk_start=np.arange(0,chnk_ult,3000000)
chnk_end=chnk_start+3e6
chnk_arr=np.arange(1,len(chnk_end))
print(chnk_start, chnk_end, chnk_arr)

我想從上面的 output 創建 3 個不同的 bash 數組。 在終端是可行的。 我想在 nextflow 腳本中使用相同的命令來創建稍后將使用的 arrays。 到目前為止,我已經嘗試過:

process imputation {
publishDir params.out, mode:'copy'
input:
tuple val(chrom),path(in_haps),path(input_bed),path(refs),path(maps) from imp_ch
output:
tuple("${chrom}"),path("${chrom}.*") into imputed
script:
def (haps,sample)=in_haps
def (bed, bim, fam)=input_bed
def (haplotype, legend, samples)=refs
"""
x="\$(make_chunk.py ${bim})"
eval \$(echo \$x | sed 's|,| |g; s|\\[|list1=(|; s|\\[|list2=(|; s|\\[|list3=(|;s|\\]|)\\n|g;')
start="\$(echo \${list1[@]})"
end="\$(echo \${list2[@]})"
chunks="\$(echo \${list3[@]})"
impute4 -g "${haps}" -h "${haplotype}" -l "${legend}" -m "${maps}" -o "${chrom}.step10.imputed.chunk\${chunks}" -no_maf_align -o_gz -int \${start[\${chunks}]} \${end[\${chunks}]} -Ne 20000 -buffer 1000 -seed 54321
"""
}

對於上面的 nextflow 過程,我收到以下錯誤:

Command error: .command.sh: line 7: 0 1 2 3 4 5 6: syntax error in expression (error token is "1 2 3 4 5 6"

但是在 bash 終端中,這些命令可以正常工作。 對這件事有什么幫助嗎?

如果您的 bimfile 只是一個空格分隔的文件,請使用nextflow 運算符來拆分此類文件:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM