This example illustrates how a Grakn Knowledge Graph can be used to simplify a bioinformatician's workflow with BLAST.
-
Open Terminal/Command Prompt:
-
Type in
git clone git@github.com:graknlabs/biograkn.git, press enter and wait for the cloning to complete. -
Type in
cd biograkn/examples/blastand press enter. -
Unzip the downloaded file. (if you use a package installer such as brew, you'll have access to the
grakncommand from anywhere in terminal). -
Type in
path-to-the-unzipped-folder/grakn server start, press enter and wait for the Grakn Server to start. -
Type in
path-to-the-unzipped-folder/grakn console --keyspace proteins --file path-to-the-blast-folder/schema.gql, press enter and wait for the schema to be loaded into theproteinskeyspace. -
Download and Install Python3:
-
Download and Install pip3:
-
While in the blast folder via Terminal/Command Prompt:
- Type in
pip3 install grakn, press enter and wait for the installation to complete. - Type in
pip3 install biopython, press enter and wait for the installation to complete. - Type in
python3 migrate.py, press enter and wait for the migration to complete. - Type in
python3 blast.py, press enter and wait for the BLAST search to complete. This can take a few minutes. - Type in
python3 queries.py, press enter and interact with the terminal to observe some Graql queries in action.
- Type in
Some of the following instructions assume that you have a basic knowledge of writing Python code.
The query to extract target sequences is placed as the value of q_match_target_sequences variable in the query_target_sequences() method of the blast.py file.
If you have already gone through the Quick Start section, first you need to clean the proteins keyspace:
-
- Enter the keyspace via Grakn Console:
path-to-grakn-dist-directory(the unzipped folder)/grakn console --keyspace proteins
- Enter the keyspace via Grakn Console:
-
- Remove both the schema definitions and data instances:
clean
- Remove both the schema definitions and data instances:
-
confirm
-
- Reload the schema:
path-to-grakn-dist-directory(the unzipped folder)/grakn console --keyspace proteins --file path-to-cloned-biograkn-repository/examples/blast/schema.gql
- Reload the schema:
Next, you need to modify the migrate.py file to specify the title the file that contains the proteins and their sequences. The current code reads from a .fasta file exported from UniProt.
For migrating data in a different format, check out the migration examples
Once you are done modifying the code in migrate.py, cd into the blast directory and run python3 migrate.py
The code in blast.py uses the qblast() method of the Biopython library, which currently does not support running BLAST requests against a BLAST Cloud instance.
However, the forked version here provides such support. To use this version instead, take the following steps:
- run
git clone git@github.com:sorsaffari/biopython.git - run
cd biopython - run
pip3 uninstall biopython - Install biopython from source
- modify the
blast.pyfile to:- change the url passed to the
qblast()method to that of your private cloud instance - add
username="blast"andpassword="your instance id"to the parameters passed toqblast()
- change the url passed to the
- run
python3 blast.py
Modify the blast.py file to replace the call to qblast() with NcbiblastxCommandline() as instructed by Biopython here.