Skip to content

Commit

Permalink
Merge pull request #17 from KCCG/cram2
Browse files Browse the repository at this point in the history
CRAM
  • Loading branch information
drmjc authored May 6, 2022
2 parents 54dccc8 + 31bf82e commit e645f20
Show file tree
Hide file tree
Showing 21 changed files with 365 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
test/*.bam filter=lfs diff=lfs merge=lfs -text
test/*.bai filter=lfs diff=lfs merge=lfs -text
*.cram filter=lfs diff=lfs merge=lfs -text
*.bam filter=lfs diff=lfs merge=lfs -text
*.bai filter=lfs diff=lfs merge=lfs -text
*.crai filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RUN \
#RUN pip install -i https://test.pypi.org/simple/ mitywgs==0.2.2rc2

# Install mity
RUN pip install mitywgs==0.3.1
RUN pip install mitywgs==0.4.0

WORKDIR /home

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Installation instructions via Docker, pip, or manually are available in [INSTALL
This is an example of calling variants in the Ashkenazim Trio.

## mity call
First run `mity call` on three MT BAMs provided in [mity/test_in](https://github.com/KCCG/mity/blob/master/test_in).
First run `mity call` on three MT BAMs provided in [mity/test_in](https://github.com/KCCG/mity/blob/master/test_in). CRAM files are supported.

We recommend always using `--normalise`, or `mity report` won't work:
```bash
Expand Down Expand Up @@ -152,7 +152,7 @@ should interpret and validate tier 3 variant still holds.
We would appreciate any feedback you may have on this.

## CRAM support
mity currently does not support CRAM, but we plan to add this.
CRAM support was added to `mity call` in v0.4.0.

# Acknowledgements
We would like to thank:
Expand Down
2 changes: 1 addition & 1 deletion Readme.Developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ samtools view -b -o NA12878.alt_bwamem_GRCh38DH.20150718.CEU.low_coverage.chrM.b

# Docker
```
version=0.3.1
version=0.4.0
docker build --tag=latest --tag=$version --tag=drmjc/mity:latest --tag=drmjc/mity:$version .
docker push drmjc/mity # equivalent to docker push drmjc/mity:latest
docker push drmjc/mity:$version
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ function docker {
docker run drmjc/mity version
}
#test
public && docker
public
wait 20 && docker
2 changes: 1 addition & 1 deletion mitylib/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1"
__version__ = "0.4.0"
6 changes: 3 additions & 3 deletions mitylib/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def do_call(bam_files, reference, genome=None, prefix=None, min_mq=30, min_bq=24
out_folder_path=".", region=None):
"""
Run mity call.
:param bam_files: a list of bam_files
:param bam_files: a list of bam or cram files
:param reference: the path to the reference genome file (fasta format)
:param genome: the path to the reference genome file for gsort (genome format). Required if normalise=True
:param prefix: The result filename prefix. If None, then the first bam_file prefix
Expand All @@ -34,13 +34,13 @@ def do_call(bam_files, reference, genome=None, prefix=None, min_mq=30, min_bq=24

if len(bam_files) > 1 and prefix is None:
raise ValueError(
"If there is more than one bam file, --prefix must be set")
"If there is more than one bam/cram file, --prefix must be set")

check_missing_file(bam_files, die=True)
prefix = create_prefix(bam_files[0], prefix)

if not all(map(bam_has_RG, bam_files)):
logging.error("At least one BAM file lacks an @RG header")
logging.error("At least one BAM/CRAM file lacks an @RG header")
exit(1)

if normalise and genome is None:
Expand Down
12 changes: 7 additions & 5 deletions mitylib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def tmp_mity_file_name():
def create_prefix(file_name, prefix=None):
"""
Most mity functions have an optional prefix. If a prefix is not specified,
then use the file name (minus the .vcf.gz or .bam suffix) as the prefix.
:param file_name: The vcf, bam, bed filename
then use the file name (minus the .vcf.gz, .bam or .cram suffix) as the prefix.
:param file_name: The vcf, bam, cram, bed filename
:param prefix: The optional prefix. If None, then create a prefix from
file_name, else return prefix
:return: str prefix
Expand All @@ -61,6 +61,8 @@ def create_prefix(file_name, prefix=None):
prefix = [os.path.basename(file_name).split(".vcf")[0], prefix][prefix is not None]
elif ".bam" in file_name:
prefix = [os.path.basename(file_name).split(".bam")[0], prefix][prefix is not None]
elif ".cram" in file_name:
prefix = [os.path.basename(file_name).split(".cram")[0], prefix][prefix is not None]
else:
raise ValueError("Unsupported file type")
return prefix
Expand Down Expand Up @@ -332,7 +334,7 @@ def vcf_get_mt_contig(vcf):
def bam_get_mt_contig(bam, as_string=False):
"""
get the mitochondrial contig name and length from a BAM file
:param bam: path to a bam file
:param bam: path to a bam or cram file
:return: a tuple of contig name as str and length as int
>>> bam_get_mt_contig('NA12878.alt_bwamem_GRCh38DH.20150718.CEU.low_coverage.chrM.bam', False)
Expand All @@ -355,9 +357,9 @@ def bam_get_mt_contig(bam, as_string=False):

def bam_has_RG(bam):
"""
Does the BAM File have an @RG header? This is critical for mity to correctly call variants.
Does the BAM or CRAM File have an @RG header? This is critical for mity to correctly call variants.
:param bam: str: path to bam file
:param bam: str: path to bam or cram file
:return: True/False
>>> bam_has_RG('NA12878.alt_bwamem_GRCh38DH.20150718.CEU.low_coverage.chrM.bam')
"""
Expand Down
Loading

0 comments on commit e645f20

Please sign in to comment.