生信小白__君君

生物信息学分析__学习笔记&日常

用bowtie2、samtools...的代码

if you wanna use(must load) the file.fastq to alig to other reference file.fasta(load from the NCBI)

[bowtie2]

$$bowtie2-build reference.fasta ref   # become 6 binary file

[bowtie2][samtools]

$$bowtie2 ( –end-to-end ) -x ref -U file.fastq -S file.sam   # make a file.sam & -end-to-end means “Gobal alignment

$$samtools  view -Sb file.sam > file.bam  # make a file.bam

$$samtools sort file.bam file_sorted  # make a file_sorted.bam

maybe make a file.bed

[bedtools]

$$bedtools bamtobed file.bam > file.bed


LOOP:

for i in 00{1..8}.fastq;

do name=${i%.fastq};

bowtie2 -p 4 -x cd119 $name.fastq -S $name.sam && samtools view -Sb $name.sam -o $name.bam && samtools sort $name.bam $name.sort && samtools index $name.sort.bam;

done


SUPER LOOP:

#Array of fastq

arrayFastq=(01 02 03 04 05 06 07 08 09 10 11 12 13 14 15) 

#Array of fasta

arrayFasta=(CDMH1 phiCD38-2) 

for a in ${arrayFasta[@]}

do

    for q in ${arrayFastq[@]} 

    do      

    echo "Aligning "${q} "to "${a}" ..."

    filename=${a}"_"${q}      

    bowtie2 -x ${a} -U ${q}.fastq -S ${filename}.sam && samtools vie       w -Sb ${filename}.sam -o ${filename}.bam && samtools sort ${file     na me}.bam ${filename}.sort && samtools index ${filename}.sort.b     am

    echo -e "Finished\n"            

    done

done

评论