<commit_before># Summarize sequencing library quality of 10x Genomics Chromium linked reads

# The reference genome.
lrref=GRCh38-2.1.0

# Report run time and memory usage.
export SHELL=zsh -opipefail
export REPORTTIME=1
export TIMEFMT=time user=%U system=%S elapsed=%E cpu=%P memory=%M job=%J
time=command time -v -o $@.time

.DELETE_ON_ERROR:
.SECONDARY:
.PHONY: all lrbasic lrwgsvc

# Run the entire analysis.
all: data/SHA256 lrbasic lrwgsvc

# Extract the barcodes from the reads using Longranger basic.
lrbasic: \
	hg002g1.lrbasic.fq.gz \
	hg003g1.lrbasic.fq.gz \
	hg004g1.lrbasic.fq.gz

# Align reads to the target genome, call variants, and create a Loupe file.
lrwgsvc: \
	hg002g1.lrwgsvc.bam \
	hg003g1.lrwgsvc.bam \
	hg004g1.lrwgsvc.bam

# Download the human reference genome.
data/grch38.fa.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp.ensembl.org/pub/release-90/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna.primary_assembly.fa.gz

# Download the Long Ranger-compatible human reference genome.
data/refdata-%.tar.gz:
	curl -o $@ http://cf.10xgenomics.com/supp/genome/$@

# Extract the Long Ranger-compatible human reference genome.
data/refdata-%/genome: data/refdata-%.tar.gz
	tar -x -C data -f $<
	touch $@

# Download the HG002 linked reads data.
data/hg002/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG002_NA24385_son/10Xgenomics_ChromiumGenome/NA24385.fastqs/$(@F)

# Download the HG003 linked reads data.
data/hg003/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG003_NA24149_father/10Xgenomics_ChromiumGenome/NA24149.fastqs/$(@F)

# Download the HG004 linked reads data.
data/hg004/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG004_NA24143_mother/10Xgenomics_ChromiumGenome/NA24143.fastqs/$(@F)

# Symlink the HG002 data.
data/hg002g1.fq.gz: data/hg002/read-RA_si-GCACAATG_lane-001-chunk-0002.fastq.gz
	ln -s hg002/$(<F) $@

# Symlink the HG003 data.
data/hg003g1.fq.gz: data/hg003/read-RA_si-GCTACTGA_lane-001-chunk-0002.fastq.gz
	ln -s hg003/$(<F) $@

# Symlink the HG004 data.
data/hg004g1.fq.gz: data/hg004/read-RA_si-GAGTTAGT_lane-001-chunk-0002.fastq.gz
	ln -s hg004/$(<F) $@

# Compute the SHA-256 of the data and verify it.
data/SHA256: \
		data/grch38.fa.gz \
		data/refdata-GRCh38-2.1.0.tar.gz \
		data/hg002g1.fq.gz \
		data/hg003g1.fq.gz \
		data/hg004g1.fq.gz
	gsha256sum -c SHA256
	gsha256sum $^ >$@

# Extract the barcodes from the reads using Longranger basic.
%_lrbasic/outs/barcoded.fastq.gz: data/%.fq.gz
	mkdir -p data/$*
	ln -sf $$(realpath $<) data/$*/
	command time longranger basic --id=$*_lrbasic --fastqs=data/$*

# Symlink the longranger basic FASTQ file.
%.lrbasic.fq.gz: %_lrbasic/outs/barcoded.fastq.gz
	ln -sf $< $@

# Align reads to the target genome, call variants, and create a Loupe file.
%_lrwgsvc/outs/possorted_bam.bam: data/%.fq.gz data/refdata-$(lrref)/genome
	mkdir -p data/$*
	ln -sf $$(realpath $<) data/$*/
	command time longranger wgs --vconly --id=$*_lrwgsvc --reference=data/refdata-$(lrref) --fastqs=data/$*

# Symlink the longranger wgs bam file.
%.lrwgsvc.bam: %_lrwgsvc/outs/possorted_bam.bam
	ln -sf $< $@<commit_msg>Align reads to the reference genome using BWA<commit_after># Summarize sequencing library quality of 10x Genomics Chromium linked reads

# The reference genome.
ref=GRCh38

# The Longranger reference genome.
lrref=GRCh38-2.1.0

# Number of threads.
t=8

# gzip compression program. Use pigz for parallelized compression.
gzip=pigz -p$t

# Report run time and memory usage.
export SHELL=zsh -opipefail
export REPORTTIME=1
export TIMEFMT=time user=%U system=%S elapsed=%E cpu=%P memory=%M job=%J
time=command time -v -o $@.time

.DELETE_ON_ERROR:
.SECONDARY:
.PHONY: all lrbasic lrwgsvc bwa

# Run the entire analysis.
all: data/SHA256 lrbasic lrwgsvc bwa

# Extract the barcodes from the reads using Longranger basic.
lrbasic: \
	hg002g1.lrbasic.fq.gz \
	hg003g1.lrbasic.fq.gz \
	hg004g1.lrbasic.fq.gz

# Align reads to the reference genome, call variants, and create a Loupe file.
lrwgsvc: \
	hg002g1.lrwgsvc.bam \
	hg003g1.lrwgsvc.bam \
	hg004g1.lrwgsvc.bam

# Align reads to the reference genome using BWA.
bwa: \
	hg002g1.lrbasic.bwa.sort.bam.bai \
	hg003g1.lrbasic.bwa.sort.bam.bai \
	hg004g1.lrbasic.bwa.sort.bam.bai

# Download the human reference genome.
data/GRCh38.fa.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp.ensembl.org/pub/release-90/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna.primary_assembly.fa.gz

# Uncompress data.
data/%.fa: data/%.fa.gz
	mkdir -p $(@D)
	gunzip -c $< >$@

# Download the Long Ranger-compatible human reference genome.
data/refdata-%.tar.gz:
	curl -o $@ http://cf.10xgenomics.com/supp/genome/$@

# Extract the Long Ranger-compatible human reference genome.
data/refdata-%/genome: data/refdata-%.tar.gz
	tar -x -C data -f $<
	touch $@

# Download the HG002 linked reads data.
data/hg002/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG002_NA24385_son/10Xgenomics_ChromiumGenome/NA24385.fastqs/$(@F)

# Download the HG003 linked reads data.
data/hg003/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG003_NA24149_father/10Xgenomics_ChromiumGenome/NA24149.fastqs/$(@F)

# Download the HG004 linked reads data.
data/hg004/%.fastq.gz:
	mkdir -p $(@D)
	curl -o $@ ftp://ftp-trace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG004_NA24143_mother/10Xgenomics_ChromiumGenome/NA24143.fastqs/$(@F)

# Symlink the HG002 data.
data/hg002g1.fq.gz: data/hg002/read-RA_si-GCACAATG_lane-001-chunk-0002.fastq.gz
	ln -s hg002/$(<F) $@

# Symlink the HG003 data.
data/hg003g1.fq.gz: data/hg003/read-RA_si-GCTACTGA_lane-001-chunk-0002.fastq.gz
	ln -s hg003/$(<F) $@

# Symlink the HG004 data.
data/hg004g1.fq.gz: data/hg004/read-RA_si-GAGTTAGT_lane-001-chunk-0002.fastq.gz
	ln -s hg004/$(<F) $@

# Compute the SHA-256 of the data and verify it.
data/SHA256: \
		data/GRCh38.fa.gz \
		data/refdata-GRCh38-2.1.0.tar.gz \
		data/hg002g1.fq.gz \
		data/hg003g1.fq.gz \
		data/hg004g1.fq.gz
	gsha256sum -c SHA256
	gsha256sum $^ >$@

# Extract the barcodes from the reads using Longranger basic.
%_lrbasic/outs/barcoded.fastq.gz: data/%.fq.gz
	mkdir -p data/$*
	ln -sf $$(realpath $<) data/$*/
	command time longranger basic --id=$*_lrbasic --fastqs=data/$*

# Symlink the longranger basic FASTQ file.
%.lrbasic.fq.gz: %_lrbasic/outs/barcoded.fastq.gz
	ln -sf $< $@

# Align reads to the reference genome, call variants, and create a Loupe file.
%_lrwgsvc/outs/possorted_bam.bam: data/%.fq.gz data/refdata-$(lrref)/genome
	mkdir -p data/$*
	ln -sf $$(realpath $<) data/$*/
	command time longranger wgs --vconly --id=$*_lrwgsvc --reference=data/refdata-$(lrref) --fastqs=data/$*

# Symlink the longranger wgs bam file.
%.lrwgsvc.bam: %_lrwgsvc/outs/possorted_bam.bam
	ln -sf $< $@

# BWA

# Index the reference genome.
%.fa.bwt: %.fa
	bwa index $<

# Align paired-end reads to the draft genome using BWA-MEM.
%.bwa.sam.gz: %.fq.gz data/$(ref).fa.bwt
	bwa mem -t$t -pC data/$(ref).fa $< | $(gzip) >$@

# samtools

# Index a FASTA file.
%.fa.fai: %.fa
	samtools faidx $<

# Sort a compressed SAM file and convert to BAM.
%.sort.bam: %.sam.gz
	samtools sort -@$t -Obam -o $@ $<

# Index a BAM file.
%.bam.bai: %.bam
	samtools index $<
{'fraction_non_alphanumeric': 0.14985163204747776, 'fraction_numerical': 0.05597518208794173, 'mean_word_length': 3.710927573062262, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1124972', 'n_tokens_mistral': 3610, 'n_tokens_neox': 3131, 'n_words': 671}