Pass two separated arguments to a makefile recipe
2
0
Entering edit mode
8.0 years ago
Marta R. • 0

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 sequencing mapping fastq • 2.0k views
ADD COMMENT
2
Entering edit mode
8.0 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

or just

    flexbar -r $< -p $(subst _1,_2,$<) 
ADD REPLY
0
Entering edit mode
$(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 REPLY

Login before adding your answer.

Traffic: 1462 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6