Your SlideShare is downloading. ×
0
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Make
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Make

505

Published on

My short course about "Make"/"Makefile" and bioinformatics. January 2013

My short course about "Make"/"Makefile" and bioinformatics. January 2013

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
505
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Make Pierre Lindenbaum http://plindenbaum.blogspot.com @yokofakun(http://twitter.com/yokofakun) INSERM-UMR1087 Nantes January 2013https://github.com/lindenb/courses/tree/master/about.make
  • 2. Problem
  • 3. Build a C program
  • 4. Make a protein#!/bin/bashTRANSCRIPT=catTRANSLATE=catrm -f merge.proteinfor DNA in file1.dna file2.dna file3.dnado echo "ATGCTAGTAGATGC" > ${DNA} ${TRANSCRIPT} ${DNA} > ${DNA/%.dna/.rna} ${TRANSLATE} ${DNA/%.dna/.rna} > ${DNA/%.dna/.pep} cat ${DNA/%.dna/.pep} >> merge.proteindone
  • 5. What if file1.pep already exists ?
  • 6. Solution: Test if file exists#!/bin/bashTRANSCRIPT=catTRANSLATE=catrm -f merge.proteinfor DNA in file1.dna file2.dna file3.dnado echo "ATGCTAGTAGATGC" > ${DNA} ${TRANSCRIPT} ${DNA} > ${DNA/%.dna/.rna} if [ ! -f ${DNA/%.dna/.pep} ] then ${TRANSLATE} ${DNA/%.dna/.rna} > ${DNA/%.dna/.pep} fi cat ${DNA/%.dna/.pep} >> merge.proteindone
  • 7. What if file1.pep is outdated ?
  • 8. Parallelization ?
  • 9. GNU make
  • 10. "a utility that automaticallybuilds executable programs and libraries from source code by reading files called makefiles"
  • 11. 1977
  • 12. TARGET1: DEPENDENCIES COMMAND-LINES1 COMMAND-LINES2 COMMAND-LINES3
  • 13. MakefileTRANSCRIPT=catTRANSLATE=catmerged.protein: file1.pep file2.pep file3.pep cat file1.pep file2.pep file3.pep > merged.proteinfile1.pep: file1.rna ${TRANSLATE} file1.rna > file1.pepfile1.rna : file1.dna ${TRANSCRIPT} file1.dna > file1.rnafile1.dna: echo "ATGCTAGTAGATGC" > file1.dna
  • 14. Outputecho "ATGCTAGTAGATGC" > file1.dnacat file1.dna > file1.rnacat file1.rna > file1.pepecho "ATGCTAGTAGATGC" > file2.dnacat file2.dna > file2.rnacat file2.rna > file2.pepecho "ATGCTAGTAGATGC" > file3.dnacat file3.dna > file3.rnacat file3.rna > file3.pepcat file1.pep file2.pep file3.pep > merged.protein
  • 15. If one file is removed$ rm file2.rna$ makecat file2.dna > file2.rnacat file2.rna > file2.pepcat file1.pep file2.pep file3.pep > merged.protein
  • 16. If one file is changed$ touch file1.dna file3.pep$ makecat file1.dna > file1.rnacat file1.rna > file1.pepcat file1.pep file2.pep file3.pep > merged.protein
  • 17. Special variables
  • 18. "name of the target" : $@TRANSCRIPT=catTRANSLATE=catmerged.protein: file1.pep file2.pep file3.pep cat file1.pep file2.pep file3.pep > $@file1.pep: file1.rna ${TRANSLATE} file1.rna > $@file1.rna : file1.dna ${TRANSCRIPT} file1.dna > $@file1.dna: echo "ATGCTAGTAGATGC" > $@
  • 19. "name of the first dependency" : $<TRANSCRIPT=catTRANSLATE=catmerged.protein: file1.pep file2.pep file3.pep cat file1.pep file2.pep file3.pep > $@file1.pep: file1.rna ${TRANSLATE} $< > $@file1.rna : file1.dna ${TRANSCRIPT} $< > $@file1.dna: echo "ATGCTAGTAGATGC" > $@
  • 20. "all the dependencies" : $^TRANSCRIPT=catTRANSLATE=catmerged.protein: file1.pep file2.pep file3.pep cat $^ > $@file1.pep: file1.rna ${TRANSLATE} $< > $@file1.rna : file1.dna ${TRANSCRIPT} $< > $@file1.dna: echo "ATGCTAGTAGATGC" > $@file2.pep: file2.rna
  • 21. Rules
  • 22. How to create a *.pep or a *.rna ?TRANSCRIPT=catTRANSLATE=cat%.pep:%.rna ${TRANSLATE} $< > $@%.rna:%.dna ${TRANSCRIPT} $< > $@merged.protein: file1.pep file2.pep file3.pep cat $^ > $@file1.dna: echo "ATGCTAGTAGATGC" > $@file2.dna: echo "ATGCTAGTAGATGC" > $@file3.dna: echo "ATGCTAGTAGATGC" > $@
  • 23. Outputecho "ATGCTAGTAGATGC" > file1.dnacat file1.dna > file1.rnacat file1.rna > file1.pepecho "ATGCTAGTAGATGC" > file2.dnacat file2.dna > file2.rnacat file2.rna > file2.pepecho "ATGCTAGTAGATGC" > file3.dnacat file3.dna > file3.rnacat file3.rna > file3.pepcat file1.pep file2.pep file3.pep > merged.prot
  • 24. Useful options
  • 25. -B "Unconditionally make all targets"
  • 26. -f FILE "Read FILE as a makefile"
  • 27. -j [N] "Allow N jobs at once"
  • 28. -n "Dont actually run any commands; just print them"
  • 29. .PHONY targets.PHONY: all cleanall: file1.dnafile1.dna: echo "ATGCTAGTAGATGC" > $@clean: rm -f file1.dna
  • 30. Function Call Syntax$(function arg1,arg2,arg3...)
  • 31. Loops: $(foreach var,list,...)merged.protein: $(foreach INDEX,1 2 3,file${INDEX}.pep ) cat $^ > $@
  • 32. $(eval )TRANSCRIPT=catTRANSLATE=catINDEXES=1 2 3%.pep:%.rna ${TRANSLATE} $< > $@%.rna:%.dna ${TRANSCRIPT} $< > $@merged.protein: $(foreach INDEX,${INDEXES},file${INDEX} cat $^ > $@$(foreach INDEX,${INDEXES},$(eval file${INDEX}: echo "ATGCTAGTAGATGC" > $$@ ))
  • 33. $(subst ee,EE,feet on the street) ‘fEEt on the strEEt’.$(patsubst %.c,%.o,x.c.c bar.c) ‘x.c.o bar.o’. $(strip a b c )‘a b c’
  • 34. $(filter %.c,src1.c src2.c src3.c file.txt) $(filter-out %.c,src1.c src2.c src3.c file.txt)$(sort foo bar lose)$(word 2, foo bar baz) bar$(wordlist 2, 3, foo bar baz)‘bar baz’.$(firstword foo bar)‘foo’.$(lastword foo bar)‘bar’.
  • 35. $(dir src/foo.c hacks)‘src/ ./’$(notdir src/foo.c hacks)‘foo.c hacks’$(suffix src/foo.c src-1.0/bar.c hacks)‘.c .c’$(basename src/foo.c src-1.0/bar hacks)‘src/foo src-1.0/bar hacks’$(addsuffix .c,foo bar)‘foo.c bar.c’.$(addprefix src/,foo bar)‘src/foo src/bar’
  • 36. (join a b,.c .o)‘a.c b.o’$(shell cat file1.txt)
  • 37. END

×