Skip to content

Commit

Permalink
chore: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
GCS-ZHN committed Dec 27, 2023
1 parent 7948476 commit 8e8e64f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,49 @@ diamond.blastp(
out="test_output"
)
```

### Advanced usage.

Some parameter options are not implemented in current release,
You could directly use it like this.

```python
diamond.blastp(
query="test_proteins.fasta",
out="test_blastp_output",
outfmt=OutFormat.BLAST_TABULAR,
sensitivity=Sensitivity.DEFAULT,
top=5 # `--top` option is not directly defined
block_size=2.0 # `--block-size` is not directly defined
)
```

and you can global change the tabular output with customed title by
```python
OutFormat.BLAST_TABULAR.with_extra_option(
"qseqid", "qstart",
"qend", "qlen", "sseqid"
) # it will change it globally

# call this will reset to default
OutFormat.BLAST_TABULAR.reset()
```

In fact, you can call the original C++ main method like this:
````python
from .libdiamond import main
args = ['bastp', '--query', 'data.fasta', '--db', 'db.dmnd']
main(*args)
````
But it is not recommended because the original C++ api lacks necessary
interface encapsulation and parameter checking. At the same time,
it is not pythonic enough, and there is no parameter reminder during programming
unless you read the original parameter document.

## How to contrib
The core of python wrap is to use custom python methods and `Diamond._build_options` to
call the `libdiamond.main` method More convenient packaging.
Therefore, anyone can make customized extensions through the
above ideas. I maintains this project after work,
so I cannot make it in time Keep up to date with all
diamond developments. Everyone is welcome to submit PRs.
5 changes: 3 additions & 2 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"qend", "qlen", "sseqid"
),
sensitivity=Sensitivity.DEFAULT,
top=5
top=5,
block_size=2.0
)

diamond.blastx(
query="test_dna.fasta",
out="test_blastx_output",
outfmt=OutFormat.BLAST_TABULAR.reset().value,
top=10
max_target_seqs=10
)

diamond.test()
Expand Down

0 comments on commit 8e8e64f

Please sign in to comment.