Hi Valeriu, Thanks for your reply. It's good to know you can pipe the -c option that way.
With a bit of trial and error, I'd gotten something similar to work for me to convert CanFam3 UCSC to ENSEMBL Best, Marsha On Tue, Jun 22, 2021 at 10:46 AM Valeriu Ohan <v...@sanger.ac.uk> wrote: > Hi, > > > > That particular regular expression is tied to Chr prefixed contigs and > even if you could OR in a rule for matching SN:M, you would want to apply > different context dependent transformations. Your best bet is with a two > chained reheader transformations: > > > > samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)Chr/\$1\$2/"' in.bam | > ./samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:M)\t/\$1\$2T\t/"' - > > out.bam > > > > *From:* Marsha Wallace <md...@cornell.edu> > *Sent:* 17 June 2021 15:39 > *To:* samtools-help@lists.sourceforge.net > *Subject:* [Samtools-help] Samtools Reheader help request [EXT] > > > > Hi, > > > > I'd like to use samtools reheader to convert bam files from UCSC ('chr' > prefix) to ENSEMBL (no 'chr' prefix) chromosome names. > > > > The current documentation at > http://www.htslib.org/doc/samtools-reheader.html > > gets me most of the way there with the example: > > - Remove “Chr” prefix > > samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)Chr/\$1\$2/"' in.bam > > > > To complete the chromosome notation conversion, I also need to rename the > mitochondrial chromosome from UCSC to ENSEMBL notation (M to MT). It would > be ideal to do this in the same command as removing the 'chr' prefix. > However, I'm not familiar enough with perl expressions to integrate a > change in the above example, and whether the above example would need a > pipe to the second MT expression, a second -c 'perl -pe' flag, or some > combination of both. > > > > Given the existing examples in the samtools documentation, my guess is > this kind of chromosome notation conversion is the most common use for > Samtools reheader, so it may also be beneficial to include the solution for > this MT conversion in the documentation. > > > > Thank you in advance! > > > > Marsha > -- The Wellcome Sanger Institute is operated by Genome Research Limited, a > charity registered in England with number 1021457 and a company registered > in England with number 2742969, whose registered office is 215 Euston Road, > London, NW1 2BE. >
_______________________________________________ Samtools-help mailing list Samtools-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/samtools-help