im using samtool to extract specific regions from the sorted bam  file/bam.bai file. e.g if i want to extract the sequence from 329729 to 329840 of chromosome one, then how would i proceed???
the command that im using is   

    ./samtools view alignment.sorted.bam gnl|BGIA2|CA_chr1:329729-329840


 and im getting following error:

    -bash: BGIA2: command not found
    -bash: CA_chr1:329729-329840: command not found
    [main_samview] region "gnl" specifies an unknown reference name. Continue anyway.


while the  "gnl|BGIA2|CA_chr1" could be found in bam file if is viewed by head command.

further how to extract the multiple sequences with the similar formate in separate file using samtool or any other tool???
thanks
Hello,

the problem is the `|` in the name. This is interpreted as a pipe to stream the output to the next program, Try to escape this symbol by `\` (Didn't test it)

    ./samtools view alignment.sorted.bam gnl\|BGIA2\|CA_chr1:329729-329840

Another way could be to create a bed file with the coordinates and use the `-L` parameter.

fin swimmer