Question: Pass two separated arguments to a makefile recipe
0
gravatar for Marta R.
4.4 years ago by
Marta R. 0
Berlin, DE
Marta R. 0 wrote:

Hi,

I have tons of fastq files that I need to analyze, and I'm creating a Makefile template (to be filled with python+jinja2) to make all speedy and robust. Just as a clarification, I'm pretty new to Make in general :)

My main problem is that sometimes i will have paired end data, and I'm not really sure how to pass paired files to a command where the arguments have to be specificed with different flags ([???] in the example). With non-paired I could use $^ but in this case it doesn't seem to be suitable.

Any ideas? :)


fastq_p1 := $(wildcard *_1.fastq.gz)
fastq_p2 := $(wildcard *_2.fastq.gz)
fastq_p1_trimmed := $(fastq_p1:_1.fastq.gz=_1.trimmed.fastq.gz)
fastq_p2_trimmed := $(fastq_p1:_1.fastq.gz=_2.trimmed.fastq.gz)
bamfiles := $(fastq_p1:_1.fastq.gz=.bam)

$(fastq_p1_trimmed) $(fastq_p2_trimmed) : $(fastq_p1) $(fastq_p2)
    flexbar -r  [???] -p [???]
makefile mapping sequencing fastq • 1.3k views
ADD COMMENTlink modified 4.4 years ago • written 4.4 years ago by Marta R. 0
2
gravatar for Pierre Lindenbaum
4.4 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:

I assume that flexbar build both trimmed fastq at the same time from fastq1 and fastq2:

you can just put the 'real' values

$(fastq_p1_trimmed) $(fastq_p2_trimmed) : $(fastq_p1) $(fastq_p2)
    flexbar -r   $(fastq_p1) -p $(fastq_p2)

or you could use the `$(word function) https://www.gnu.org/software/make/manual/html_node/Text-Functions.html

$(fastq_p1_trimmed) $(fastq_p2_trimmed) : $(fastq_p1) $(fastq_p2)
    flexbar -r  $(word 1,$^) -p $(word 2,$^)

BUT

$(fastq_p1_trimmed) $(fastq_p2_trimmed) : $(fastq_p1) $(fastq_p2)
    flexbar -r  [???] -p [???]

is wrong: because make will create :

  • '$(fastq_p1)' from $(fastq_p1) and $(fastq_p2)
  • AND THEN /OR '$(fastq_p2)' from $(fastq_p1) and $(fastq_p2)

what you want is something like;

fastq_p2_trimmed is created at the same time that fastq_p1_trimmed. Just be sure that the date of modification is the most recent one.

$(fastq_p2_trimmed) : $(fastq_p1_trimmed)
    touch -c $@

$(fastq_p1_trimmed) : $(fastq_p1) $(fastq_p2)
    flexbar -r  $(word 1,$^) -p $(word 2,$^)
ADD COMMENTlink written 4.4 years ago by Pierre Lindenbaum131k

Thanks for your input, Pierre! Unfortunately, neither of the options works. Given three pairs of fastq files, using the word option outputs the first mate of the first pair of fastq and the first mate of the second pair instead of mate1 and mate2 of the first pair. See below my test case output:

make -n
flexbar -r Test/A1_1.fastq.gz -p Test/B1_1.fastq.gz
flexbar -r Test/A1_1.fastq.gz -p Test/B1_1.fastq.gz
flexbar -r Test/A1_1.fastq.gz -p Test/B1_1.fastq.gz

Edit: Nevermind! Finally found the way. I leave the fix here just in case :)

$(fastq_p1_trimmed) : $(fastq_p1)
    flexbar -r $(word 1, $^) -p $(subst _1,_2,$(word 1, $^)) 

$(fastq_p2_trimmed) : $(fastq_p1_trimmed)
    touch -c $@
ADD REPLYlink written 4.4 years ago by Marta R. 0

or just

    flexbar -r $< -p $(subst _1,_2,$<) 
ADD REPLYlink written 4.4 years ago by Pierre Lindenbaum131k
$(fastq_p1_trimmed) : $(fastq_p1)

should be (two prerequistes: if $(fastq_p2) is changed, then fastq_p1_trimmed must be recomputed

$(fastq_p1_trimmed) : $(fastq_p1) $(fastq_p2)
ADD REPLYlink written 4.4 years ago by Pierre Lindenbaum131k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2022 users visited in the last hour