<p>I would also suggest using <a href="https://www.gnu.org/software/parallel/" rel="nofollow noreferrer">GNU parallel</a> as described in our guides :</p>
<p><a href="https://docs.milaboratories.com/mixcr/guides/generic-multiplex-bcr/#one-command-solution" rel="nofollow noreferrer">https://docs.milaboratories.com/mixcr/guides/generic-multiplex-bcr/#one-command-solution</a></p>
<p>Briefly:</p>
<pre><code>ls /Documents/Data/Input/*_R1* | \
    parallel -j 4 \
    'mixcr analyze 
    …
    {} \
    {=s:R1:R2:=} \             
{=s:.*/:/Documents/Data/result/:;s:_R.*::=}'
</code></pre>
<p>That will take all fastq pairs from /Documents/Data/Input and put the result output files into /Documents/Data/result folder.</p>

CC BY-SA 4.0
2023-01-24T15:33:28.783Z
2023-01-26T16:27:20.327Z
2023-01-26T16:27:20.327Z
Mark Izraelson
<p>Here's how I'd approach this:</p>

<pre><code>for READ1 in /Documents/Data/Input/*R1*
do
    READ2=${READ1/R1/R2}
    mixcr analyze amplicon --s hs \
        --starting-material dna \
        --5-end v-primers \
        --3-end j-primers \
        --adapters no-adapters \
        --receptor-type trb \
        --only-productive "$READ1" "$READ2"
done
</code></pre>

<p>Basically, loop over all the R1 FASTQ files in a directory, and calculate the R2 names as needed.</p>

<p>This is using BASH string manipulation, and assumes that substituting <code>R2</code> for <code>R1</code> will correctly calculate the R2 filename from R1. It also assumes that all the FASTQ files are in a single directory.</p>

CC BY-SA 4.0
2019-07-01T17:13:39.097Z
Thanks.  This is essentially the approach that I took.  My original problem actually was the result of trying to run a shell command that wasn't compatible with the Linux version of shell.  When I used $ batch instead of $ sh to initiate my script, all the recommendations worked. I should have started by providing the bit of information that I am working in Linux (Ubuntu 18.04 to be exact).
Lou_A
CC BY-SA 4.0
2019-07-01T18:25:23.473Z
Ah - OK. Yes, you may want to use `bash` rather than `sh` if possible. Glad it's working for you.
Scot
CC BY-SA 4.0
2019-06-28T18:12:27.167Z
2019-06-29T01:07:55.447Z
2019-06-29T01:07:55.447Z
Scot
<p>I have a folder with 150 pairs of fastq files from an illumina sequence run. I need to precess them with mixcr, how can I do this in Bash with a single command?</p>

CC BY-SA 4.0
2019-06-27T01:54:41.137Z
What is your command for processing a single pair of FASTQ files?
Scot
CC BY-SA 4.0
2019-06-27T07:41:06.150Z
You can use a for loop.
benn
CC BY-SA 4.0
2019-06-28T12:11:02.550Z
Here's an example of the command line that I'm using to run Mixcr for a pair of samples:  mixcr analyze amplicon --s hs \--staring-material dna \--5-end v-primers \--3-end j-primers \--adapters no-adapters \--receptor-type trb \--only-productive /Documents/Data/Input/S1_S1_L001_R1_001.fastq.gz /Documents/Data/Input/S1_S1_L001_R2_001.fastq.gz  

The S1_S1_ component of the file name changes with each sample to S2_S2_  S3_S3_  all the way to 75.  I'm having a little problem setting the $variable for the file name in the loop.
Lou_A
CC BY-SA 4.0
2019-06-28T13:19:17.400Z
One solution I thought is to try to iterate through the two types of files (R1 and R2) with a FOR loop, but I can't figure out how to do this.  I don't think a nested loop will do the trick.
Lou_A
CC BY-SA 4.0
2019-06-28T16:21:55.520Z
Create a text file with two columns, one for R1 and the other for R2. Loop through this file. Shell loops are not a good thing to begin with, and nested loops are almost never required.
Ram RS
<ngs>
Mixcr batch processing
# Mixcr batch processing

(Asked by: username_0 on 2019-06-27)

I have a folder with 150 pairs of fastq files from an illumina sequence run. I need to precess them with mixcr, how can I do this in Bash with a single command?

**Tags:** ngs
> **Comments:**
> **username_1**: What is your command for processing a single pair of FASTQ files?  
> **username_2**: You can use a for loop.  
> **username_0**: Here's an example of the command line that I'm using to run Mixcr for a pair of samples:  mixcr analyze amplicon --s hs \--staring-material dna \--5-end v-primers \--3-end j-primers \--adapters no-adapters \--receptor-type trb \--only-productive /Documents/Data/Input/S1_S1_L001_R1_001.fastq.gz /Documents/Data/Input/S1_S1_L001_R2_001.fastq.gz    The S1_S1_ component of the file name changes with each sample to S2_S2_  S3_S3_  all the way to 75.  I'm having a little problem setting the $variable for the file name in the loop.  
> **username_0**: One solution I thought is to try to iterate through the two types of files (R1 and R2) with a FOR loop, but I can't figure out how to do this.  I don't think a nested loop will do the trick.  
> **username_3**: Create a text file with two columns, one for R1 and the other for R2. Loop through this file. Shell loops are not a good thing to begin with, and nested loops are almost never required.  

---

## 2 answers

### Answer by username_1 on 2019-06-28. Score: 4 | Accepted answer

Here's how I'd approach this:
for READ1 in /Documents/Data/Input/*R1*
do
    READ2=${READ1/R1/R2}
    mixcr analyze amplicon --s hs \
        --starting-material dna \
        --5-end v-primers \
        --3-end j-primers \
        --adapters no-adapters \
        --receptor-type trb \
        --only-productive "$READ1" "$READ2"
done

Basically, loop over all the R1 FASTQ files in a directory, and calculate the R2 names as needed.
This is using BASH string manipulation, and assumes that substituting R2 for R1 will correctly calculate the R2 filename from R1. It also assumes that all the FASTQ files are in a single directory.

> **Comments:**
> **username_0**: Thanks.  This is essentially the approach that I took.  My original problem actually was the result of trying to run a shell command that wasn't compatible with the Linux version of shell.  When I used $ batch instead of $ sh to initiate my script, all the recommendations worked. I should have started by providing the bit of information that I am working in Linux (Ubuntu 18.04 to be exact).  
> **username_1**: Ah - OK. Yes, you may want to use `bash` rather than `sh` if possible. Glad it's working for you.  

---

### Answer by username_4 on 2023-01-24. Score: 2

I would also suggest using GNU parallel as described in our guides :
https://docs.milaboratories.com/mixcr/guides/generic-multiplex-bcr/#one-command-solution
Briefly:
ls /Documents/Data/Input/*_R1* | \
    parallel -j 4 \
    'mixcr analyze 
    …
    {} \
    {=s:R1:R2:=} \             
{=s:.*/:/Documents/Data/result/:;s:_R.*::=}'

That will take all fastq pairs from /Documents/Data/Input and put the result output files into /Documents/Data/result folder.


---

