module
biopipen.utils.reference
Utilities for indexing reference files
Functions
bam_index
(
bam
,bamdir
,tool
,samtools
,sambamba
,ncores
,ext
,force
)
— Index a bam file</>tabix_index
(
infile
,preset
,tmpdir
,tabix
)
(str | os.pathlike) — Index input file using tabix</>
function
biopipen.utils.reference.
tabix_index
(
infile
, preset
, tmpdir=None
, tabix='tabix'
)
Index input file using tabix
- Try to check if there is an index file in the same directory where infile is.
- If so, return the infile
- Otherwise, check if infile is bgzipped, if not bgzip it and save it in tmpdir
- Index the bgzipped file and return the bgzipped file
Parameters
infile
(str | os.pathlike) — The input file to be indexedpreset
(Literal) — The preset used to index the filetmpdir
(bool | str | os.pathlike | none, optional) — The directory to link the infile there and index itIf False, try to index the infile directly. The directory where the infile is should be writable.tabix
(str, optional) — The path to tabix
Returns (str | os.pathlike)
The infile itself or re-bgzipped infile. This file comes with theindex file in the same directory
function
biopipen.utils.reference.
bam_index
(
bam
, bamdir='/tmp'
, tool='samtools'
, samtools='samtools'
, sambamba='sambamba'
, ncores=1
, ext='.bam.bai'
, force=False
)
Index a bam file
First look for the index file in the same directory as the bam file, if found, return the bam file. Otherwise, generate a symbolic link of the bam file in bamdir, and generate a index there, return the path to the symbolic link
Parameters
bam
— The path to the bam filebamdir
(optional) — If index file can't be found in the directory as the bam file,create a symbolic link to the bam file, and generate the index heretool
(optional) — The tool used to generate the index file, eithersamtools
orsambamba
samtools
(optional) — The path to samtoolssambamba
(optional) — The path to sambambancores
(optional) — Number of cores (threads) used to generate the index fileext
(optional) — The ext of the index file, default.bam.bai
, in case,.bai
isalso treated as index fileforce
(optional) — Force to generate the index file, with given bamfile.Don't check if the index file exists.
Returns
The bam file if index exists in the directory as the bam file.Otherwise symbolic link to the bam file in bamdir.