-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_to_host_genome
63 lines (46 loc) · 1.76 KB
/
map_to_host_genome
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#map to reference genome
module load bwa
module load samtools
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
bwa mem -t 8 -T 30 ~/pigref ~/clean/${SAMPLEID}_R1_001.clean.fastq.gz ~/clean/${SAMPLEID}_R2_001.clean.fastq.gz -R '@RG\tID:${SAMPLEID}_join\tPL:illumina\tSM:${SAMPLEID}_join' > ~/${SAMPLEID}.sam
done
#convert sam to bam and sort
module load samtools
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
samtools view -h -b -S ${SAMPLEID}.sam > ${SAMPLEID}.bam
samtools sort ${SAMPLEID}.bam -o ${SAMPLEID}_sorted.bam
samtools index ${SAMPLEID}_sorted.bam
done
#extract unmapped sequence
module load samtools
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
samtools view -b -f 12 -F 256 ${SAMPLEID}.bam > ${SAMPLEID}_filter.bam
done
#sort bam file
module load samtools
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
samtools sort -n ${SAMPLEID}_filter.bam -o ${SAMPLEID}_filter_sorted.bam
done
#bam to fastq
module load bedtools
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
bedtools bamtofastq -i ${SAMPLEID}_filter_sorted.bam -fq ${SAMPLEID}_r1.fastq -fq2 ${SAMPLEID}_r2.fastq
mv ${SAMPLEID)_r1.fastq ~/processed_seqs
mv ${SAMPLEID)_r2.fastq ~/processed_seqs
done
#fastp
for SAMPLEID in $(cat ~/samples.txt);
do
echo "On sample: $SAMPLEID"
fastp -A -G -Q -L -i ~/processed_seqs/${SAMPLEID}_r1.fastq -I ~/processed_seqs/${SAMPLEID}_r2.fastq -o ~/processed_seqs/${SAMPLEID}_final_R1.fastq.gz -O ~/processed_seqs/${SAMPLEID}_final_R2.fastq.gz -h ~/processed_seqs/${SAMPLEID}_final.html -j ~/processed_seqs/${SAMPLED}_final.json
done