Hi,
I have (what I think) is a valid sam file.
When I do:
samtools view -S F1i1F.C57.2.Aligned.out.sam chr19_C57
I get the follong message:
[samopen] SAM header is present: 66 sequences.
[main_samview] random alignment retrieval only works for indexed BAM files.
Note: my chromosomes are chr1_C57, chr2_C57, etc.
As far as I remember I was able to see sam files by chromosomes when using an unsorted sam file but I may be wrong. I can transform it to bam, sort it and index it, but is it necessary?
grep -P "\tchr1_C57\t" F1i1F.C57.2.Aligned.out.sam should work.
egrep '^@|chr1_C57' F1i1F.C57.2.Aligned.out.sam should get you the header too. This will only give meaningful results if the readname doesnt start with "@"
Good call, the regex is definitely a better method than using word match.