W
W
wolverine7772019-10-31 00:16:02
linux
wolverine777, 2019-10-31 00:16:02

How to run two files in a process at the same time?

Hello, just now they helped me with understanding how to script the launch of all files (with the fastqc module) that are in the folder one after the other, suppose in the /home/blabla/files/ folder there are file1.fastq, file2.fastq, file3.fastq, etc. d.
everything that is in the folder one by one - like this

for file in $(find /home/blabla/files/ -name '*.fastq')
do
        fastqc "$file" -o /home/blabla/FastQC_out
done

But what if I need to script a PAIR launch (I don’t know, do they say that at all?) Files? for example
java -jar trimmomatic-0.39.jar PE -phred33 \ 
/home/blabla/files/file1.fastq /home/blabla/files/file2.fastq 
output-file1-FOR.fastq \
output-file1-REV.fastq \
output-file2-FOR.fastq \
output-file2-REV.fastq \
ILLUMINACLIP:TruSeq3-PE-2.fa:2:30:10 LEADING:5 TRAILING:5 SLIDINGWINDOW:4:5 MINLEN:36

java -jar trimmomatic-0.39.jar PE -phred33and
ILLUMINACLIP:TruSeq3-PE-2.fa:2:30:10 LEADING:5 TRAILING:5 SLIDINGWINDOW:4:5 MINLEN:36
- these are programs with their arguments, which, in fact, process file1 and file2.
output-FOR and output-REV are output files with a result (2 for each input file).
The only catch is that they must be processed in pairs.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2019-10-31
@wolverine777

And if the folder will lie

file1
file3
file4
file5

or
file1
file10
file2
file3

Are your pairs broken?
Specify the requirements for the task - do you just need to execute a command with any two files, or are these files connected in some way and this connection can be described by an algorithm?
just two files can be muddied through find | xargs
or in a loop to select files through a condition,
but to guarantee the connection of specific files is another task

A
AUser0, 2019-10-31
@AUser0

#~/bin/bash

pat='_([0-9]+)_A'
for file in $(find ./ -name '*.fastq')
do
        if 
        then
                java -jar trimmomatic-0.39.jar PE -phred33 \
                file_${BASH_REMATCH[1]}_A.fastq \
                file_${BASH_REMATCH[1]}_B.fastq \
                output-file_${BASH_REMATCH[1]}_A-FOR.fastq \
                output-file_${BASH_REMATCH[1]}_A-REV.fastq \
                output-file_${BASH_REMATCH[1]}_B-FOR.fastq \
                output-file_${BASH_REMATCH[1]}_B-REV.fastq \
                ILLUMINACLIP:TruSeq3-PE-2.fa:2:30:10 LEADING:5 TRAILING:5 SLIDINGWINDOW:4:5 MINLEN:36
        fi
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question