Hi,

Yes, I can confirm it does csi by default, bad assumptions...

In the end I didn't need it as to avoid read write and decompression more 
tee/pee fun was needed:

samtools markdup -u... | \
  pee "bam_stats ...> out.bam.bas "\
          "samtools view... | pee 'cat > out.bam' 'samtools index - 
out.bam.bai' \
                                                     'md5sum -b > out.bam.md5'\
          "

This allows 2 items to digest the uncompressed data, while another 2 digest the 
compressed stream, outputting a total of 4 different files.

Although this is a bit more complex to read, it's much easier to swap in 
bam+bai/csi or cram+crai by placeholders, while retaining the efficiency.

Regards,

Keiran Raine, M.Sc., MBCS
Principal Software Developer
Cancer, Ageing and Somatic Mutation
Wellcome Sanger Institute

k...@sanger.ac.uk<mailto:k...@sanger.ac.uk>
Office: D3-19
Ext: 4983

Please note that due to childcare requirements during the Covid lockdown I am 
generally not available after 4pm.

From: "Nowoshilow,Sergej" <sergej.nowoshi...@imp.ac.at>
Date: Saturday, 13 June 2020 at 20:31
To: Keiran Raine <k...@sanger.ac.uk>, "samtools-help@lists.sourceforge.net" 
<samtools-help@lists.sourceforge.net>
Subject: Re: [Samtools-help] --write-index - csi? [EXT]

Hi Keiran,

I see.. Sorry, I wasn’t aware of that option as I still use 1.9.

However, this is what I found in the source code on Github.

If @p fn contains the string "##idx##" (HTS_IDX_DELIM), the part before


the delimiter will be used as the name of the data file and the part after


it will be used as the name of the index.


https://github.com/samtools/htslib/blob/34c15969fa49d78b07c649374fb008fb3ed1e98a/htslib/hts.h#L816

The following two lines suggests that it creates CSI by default
https://github.com/samtools/samtools/blob/72d140b590cbacc975e96bf40f3db6e6370a5cbe/sam_utils.c#L102
 
[github.com]<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_samtools_samtools_blob_72d140b590cbacc975e96bf40f3db6e6370a5cbe_sam-5Futils.c-23L102&d=DwMGaQ&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=0l44_2npVb7te0dQGjE0Xw&m=Fx84Cy_lzbMQXG5n1vjTOWr1jHvlJFSu2d4HFxwTwKg&s=O3am9FNEC2B4EwIwfZQQtyyV-jginOkCWHJqbtkoVvI&e=>

https://github.com/samtools/samtools/blob/72d140b590cbacc975e96bf40f3db6e6370a5cbe/sam_utils.c#L75

I cannot try it out since I don’t have samtools-1.10 right now, but maybe it 
helps.

Best,
Sergej





Dr. Sergej Nowoshilow
Post-doc in Tanaka Lab

Elly Tanaka group, IMP
Animal models of regeneration

email: sergej.nowoshi...@imp.ac.at
phone: +43 (0) 1 79730 3203
orcid: 0000-0001-8360-5010 
[orcid.org]<https://urldefense.proofpoint.com/v2/url?u=https-3A__orcid.org_0000-2D0001-2D8360-2D5010&d=DwMGaQ&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=0l44_2npVb7te0dQGjE0Xw&m=Fx84Cy_lzbMQXG5n1vjTOWr1jHvlJFSu2d4HFxwTwKg&s=fDRWss51AM3b7YqlwKdw-idlnb4Gu0h56u9rDPg5bF0&e=>

IMP
Research Institute of Molecular Pathology
Campus-Vienna-BioCenter 1
1030 Vienna, Austria

Part of Vienna BioCenter
www.viennabiocenter.org

This message is confidential and may contain privileges information. It is 
intended for the named recipients only. If you receive it in error please 
notify me and permanently delete the original message and any copies.


Von: Keiran Raine <k...@sanger.ac.uk>
Datum: Samstag, 13. Juni 2020 um 20:33
An: "Nowoshilow,Sergej" <sergej.nowoshi...@imp.ac.at>, 
"samtools-help@lists.sourceforge.net" <samtools-help@lists.sourceforge.net>
Betreff: Re: [Samtools-help] --write-index - csi? [EXT]

Hi Sergej,

"--write-index" is a valid option for samtools view in 1.10 (provided your data 
is sorted).  My question, more clearly, would be "can you specify csi index for 
bam output instead of bai"?

Regards,

Keiran Raine, M.Sc., MBCS
Principal Software Developer
Cancer, Ageing and Somatic Mutation
Wellcome Sanger Institute

k...@sanger.ac.uk<mailto:k...@sanger.ac.uk>
Office: D3-19
Ext: 4983

Please note that due to childcare requirements during the Covid lockdown I am 
generally not available after 4pm.

From: "Nowoshilow,Sergej" <sergej.nowoshi...@imp.ac.at>
Date: Saturday, 13 June 2020 at 19:30
To: Keiran Raine <k...@sanger.ac.uk>, "samtools-help@lists.sourceforge.net" 
<samtools-help@lists.sourceforge.net>
Subject: Re: [Samtools-help] --write-index - csi? [EXT]

Hi Keiran,

I don’t think so. As far as I know, samtools view is only used to convert (or 
view) SAM<->BAM<->CRAM. However, the file must not be sorted, while indexing 
implies that the file is sorted.
I’d use ‘samtools view’ to convert the file if necessary, sort it using 
‘samtools sort’ and then ‘samtools index -c’ to index the resulting file.

Best,
Sergej



Dr. Sergej Nowoshilow
Post-doc in Tanaka Lab

Elly Tanaka group, IMP
Animal models of regeneration

email: sergej.nowoshi...@imp.ac.at
phone: +43 (0) 1 79730 3203
orcid: 0000-0001-8360-5010 
[orcid.org]<https://urldefense.proofpoint.com/v2/url?u=https-3A__orcid.org_0000-2D0001-2D8360-2D5010&d=DwMGaQ&c=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo&r=0l44_2npVb7te0dQGjE0Xw&m=OUcnRnlcd1-X4t14yOV3uXvJMtfY4-xOCh6FrcpRBec&s=UPRZn_OWn3OGDmbO7f4nFs-1GyD4WTRHQnh5eKylxyI&e=>

IMP
Research Institute of Molecular Pathology
Campus-Vienna-BioCenter 1
1030 Vienna, Austria

Part of Vienna BioCenter
www.viennabiocenter.org

This message is confidential and may contain privileges information. It is 
intended for the named recipients only. If you receive it in error please 
notify me and permanently delete the original message and any copies.


Von: Keiran Raine <k...@sanger.ac.uk>
Datum: Samstag, 13. Juni 2020 um 20:16
An: "samtools-help@lists.sourceforge.net" <samtools-help@lists.sourceforge.net>
Betreff: [Samtools-help] --write-index - csi?

Hi,

Is it possible to write a csi index when using samtools view?  I can't see 
anything in the --output-fmt* section relating to index format.

Thanks,

Keiran Raine, M.Sc., MBCS
Principal Software Developer
Cancer, Ageing and Somatic Mutation
Wellcome Sanger Institute

k...@sanger.ac.uk<mailto:k...@sanger.ac.uk>
Office: D3-19
Ext: 4983

Please note that due to childcare requirements during the Covid lockdown I am 
generally not available after 4pm.
-- 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.
-- 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.



-- 
 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

Reply via email to