# Basic syntax:
samtools view -S -b sam_file.sam > bam_file.bam
# Where:
# -S specifies that the input is a sam file
# -b specified that the output should be written in bam format
# To convert a bam file to a sam file, use:
samtools view -h -o sam_file.sam bam_file.bam
samtools view -h -o yourDir/test.sam test.bam