2017-02-09 3 views
0

for 루프를 다시 작성하고 병렬로 실행하려고하지만 모든 종류의 문제가 있습니다. 여기 내 루프for-loop를 "parallel"과 함께 사용하기 위해 다시 작성

function no_sam { 
    filename=$(basename "$file") 
    extension="${file##*.}" 

    if [ $extension = "sam" ]; 
     then 
     filename="${filename%.*}" 
     feat_out=$filename.out 
     htseq-count -f $types -r "$pos" -m "$mode" -i "$attribute" -s "$strand" -t "$feature" -a "$qual" "$file" "$input_gff" > "$feat_out" 
     grep -v "_" "$feat_out" > temp && mv temp "$feat_out" 
     mv "$feat_out" "$counts_folder" 
    elif [ $extension = "bam" ]; 
     then 
     filename="${filename%.*}" 
     feat_out=$filename.out 
     htseq-count -f $types -r "$pos" -m "$mode" -i "$attribute" -s "$strand" -t "$feature" -a "$qual" "$file" "$input_gff" > "$feat_out" 
     grep -v "_" "$feat_out" > temp && mv temp "$feat_out" 
     mv "$feat_out" "$counts_folder" 
    fi  
} 

for file in "${multi[@]}"; do 
    no_sam 
done 

에 대한 그리고 내가 GNU의 평행 for 루프를 교체 할 때, 나는 점점 오전 오류입니다

"${multi[@]}" no_sam | parallel 

testfile.sam: command not found 
+0

shellcheck.net과'bash -x'를 통해 스크립트를 실행하십시오. – codeforester

+0

나는 벌써했다. 그것은 "병렬"소프트웨어를 어떻게 운영하고있는가에 대한 문제입니다. – upendra

+0

shellcheck에서 신고 한 문제를 해결 했습니까? – codeforester

답변

0

보십시오이 (https://www.gnu.org/software/parallel/man.html#EXAMPLE:-Using-shell-variableshttps://www.gnu.org/software/parallel/man.html#EXAMPLE:-Calling-Bash-functions 기준) :

function no_sam { 
    file="$1" 
    filename=$(basename "$file") 
    extension="${file##*.}" 

    if [ $extension = "sam" ]; 
     then 
     filename="${filename%.*}" 
     feat_out=$filename.out 
     htseq-count -f $types -r "$pos" -m "$mode" -i "$attribute" -s "$strand" -t "$feature" -a "$qual" "$file" "$input_gff" > "$feat_out" 
     grep -v "_" "$feat_out" > temp && mv temp "$feat_out" 
     mv "$feat_out" "$counts_folder" 
    elif [ $extension = "bam" ]; 
     then 
     filename="${filename%.*}" 
     feat_out=$filename.out 
     htseq-count -f $types -r "$pos" -m "$mode" -i "$attribute" -s "$strand" -t "$feature" -a "$qual" "$file" "$input_gff" > "$feat_out" 
     grep -v "_" "$feat_out" > temp && mv temp "$feat_out" 
     mv "$feat_out" "$counts_folder" 
    fi  
} 
export -f no_sam 

parallel no_sam ::: "${multi[@]}" 

GNU 병렬을 사용하는 방식에서 나는 man parallel_tutorial을 걷는 시간을 보내는 것이 도움이 될 것이라고 생각합니다. 커맨드 라인이 당신을 사랑합니다.