Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add agat convert minimap2 bam2gff #113

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
- `agat_convert_embl2gff`: convert an EMBL file into GFF format (PR #99).
- `agat/agat_convert_sp_gff2gtf`: convert any GTF/GFF file into a proper GTF file (PR #76).
- `agat/agat_convert_bed2gff`: convert bed file to gff format (PR #97).
- `agat/agat_convert_minimap2_bam2gff`: convert output from minimap2 (bam or sam) into gff file (PR #113).
- `agat/agat_convert_mfannot2gff`: convert MFannot "masterfile" annotation to gff format (PR #112).
- `agat/agat_convert_embl2gff`: convert an EMBL file into GFF format (PR #99).
- `agat/agat_convert_sp_gff2tsv`: convert gtf/gff file into tabulated file (PR #102).
Expand Down
75 changes: 75 additions & 0 deletions src/agat/agat_convert_minimap2_bam2gff/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: agat_convert_minimap2_bam2gff
namespace: agat
description: |
Convert output from minimap2 (bam or sam) into gff file. To
get bam from minimap2 use the following command: `minimap2 -ax splice:hq
genome.fa Asecodes_parviclava.nucest.fa | samtools sort -O BAM -o
output.bam`.
keywords: [gene annotations, GFF conversion, minimap2]
links:
homepage: https://github.com/NBISweden/AGAT
documentation: https://agat.readthedocs.io/en/latest/tools/agat_convert_minimap2_bam2gff.html
issue_tracker: https://github.com/NBISweden/AGAT/issues
repository: https://github.com/NBISweden/AGAT
references:
doi: 10.5281/zenodo.3552717
license: GPL-3.0
requirements:
commands: [agat]
authors:
- __merge__: /src/_authors/leila_paquay.yaml
roles: [ author, maintainer ]
argument_groups:
- name: Inputs
arguments:
- name: --input
alternatives: [-i]
description: Input file in SAM (.sam extension) or BAM (.bam extension) format.
type: file
required: true
direction: input
example: input.sam
- name: Outputs
arguments:
- name: --output
alternatives: [-o, --out]
description: Output GFF file.
type: file
direction: output
required: true
example: output.gff
- name: Arguments
arguments:
- name: --bam
alternatives: [-b]
description: To force the use of the input file as a BAM file.
type: boolean_true
- name: --sam
alternatives: [-s]
description: To force the use of the input file as a SAM file.
type: boolean_true
- name: --config
alternatives: [-c]
description: |
AGAT config file. By default AGAT takes the original agat_config.yaml shipped with AGAT. The `--config` option gives you the possibility to use your own AGAT config file (located elsewhere or named differently).
type: file
required: false
example: custom_agat_config.yaml
resources:
- type: bash_script
path: script.sh
test_resources:
- type: bash_script
path: test.sh
- type: file
path: test_data
engines:
- type: docker
image: quay.io/biocontainers/agat:1.4.0--pl5321hdfd78af_0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to update the docker setup so that samtools is also installed?

setup:
- type: docker
run: |
agat --version | sed 's/AGAT\s\(.*\)/agat: "\1"/' > /var/software_versions.txt
runners:
- type: executable
- type: nextflow
76 changes: 76 additions & 0 deletions src/agat/agat_convert_minimap2_bam2gff/help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
```sh
agat_convert_minimap2_bam2gff.pl --help
```

------------------------------------------------------------------------------
| Another GFF Analysis Toolkit (AGAT) - Version: v1.4.0 |
| https://github.com/NBISweden/AGAT |
| National Bioinformatics Infrastructure Sweden (NBIS) - www.nbis.se |
------------------------------------------------------------------------------


Name:
agat_convert_minimap2_bam2gff.pl

Description:
The script converts output from minimap2 (bam or sam) into gff file. To
get bam from minimap2 use the following command: minimap2 -ax splice:hq
genome.fa Asecodes_parviclava.nucest.fa | samtools sort -O BAM -o
output.bam To use bam with this script you will need samtools in your
path.

Usage:
agat_convert_minimap2_bam2gff.pl -i infile.bam [ -o outfile ]
agat_convert_minimap2_bam2gff.pl -i infile.sam [ -o outfile ]
agat_convert_minimap2_bam2gff.pl --help

Options:
if ( !GetOptions( 'i|input=s' => \$opt_in,

-i or --input
Input file in sam (.sam extension) or bam (.bam extension)
format.

-b or --bam
To force to use the input file as sam file.

-s or --sam
To force to use the input file as sam file.

-o, --out or --output
Output GFF file. If no output file is specified, the output will
be written to STDOUT.

-c or --config
String - Input agat config file. By default AGAT takes as input
agat_config.yaml file from the working directory if any,
otherwise it takes the orignal agat_config.yaml shipped with
AGAT. To get the agat_config.yaml locally type: "agat config
--expose". The --config option gives you the possibility to use
your own AGAT config file (located elsewhere or named
differently).

-h or --help
Display this helpful text.

Feedback:
Did you find a bug?:
Do not hesitate to report bugs to help us keep track of the bugs and
their resolution. Please use the GitHub issue tracking system available
at this address:

https://github.com/NBISweden/AGAT/issues

Ensure that the bug was not already reported by searching under Issues.
If you're unable to find an (open) issue addressing the problem, open a new one.
Try as much as possible to include in the issue when relevant:
- a clear description,
- as much relevant information as possible,
- the command used,
- a data sample,
- an explanation of the expected behaviour that is not occurring.

Do you want to contribute?:
You are very welcome, visit this address for the Contributing
guidelines:
https://github.com/NBISweden/AGAT/blob/master/CONTRIBUTING.md
18 changes: 18 additions & 0 deletions src/agat/agat_convert_minimap2_bam2gff/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -eo pipefail

## VIASH START
## VIASH END

# unset flags
[[ "$par_bam" == "false" ]] && unset par_bam
[[ "$par_sam" == "false" ]] && unset par_sam

# run agat_convert_sp_bed2gff.pl
agat_convert_minimap2_bam2gff.pl \
--input "$par_input" \
--output "$par_output" \
${par_bam:+--bam} \
${par_sam:+--sam} \
${par_config:+--config "${par_config}"}
35 changes: 35 additions & 0 deletions src/agat/agat_convert_minimap2_bam2gff/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -eo pipefail

## VIASH START
## VIASH END

test_dir="${meta_resources_dir}/test_data"

# create temporary directory and clean up on exit
TMPDIR=$(mktemp -d "$meta_temp_dir/$meta_functionality_name-XXXXXX")
function clean_up {
[[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR"
}
trap clean_up EXIT

echo "> Run $meta_name with test data"
"$meta_executable" \
--input "$test_dir/test_minimap2.sam" \
--output "$TMPDIR/output.gff"

echo ">> Checking output"
[ ! -f "$TMPDIR/output.gff" ] && echo "Output file output.gff does not exist" && exit 1

echo ">> Check if output is empty"
[ ! -s "$TMPDIR/output.gff" ] && echo "Output file output.gff is empty" && exit 1

echo ">> Check if output matches expected output"
diff "$TMPDIR/output.gff" "$test_dir/agat_convert_minimap2_bam2gff_1.gff"
if [ $? -ne 0 ]; then
echo "Output file output.gff does not match expected output"
exit 1
fi

echo "> Test successful"
Loading