Skip to content

Latest commit

 

History

History
 
 

blast

README.md

Importing BLAST results into a Grakn Knowledge Graph - an Example

This example illustrates how a Grakn Knowledge Graph can be used to simplify a bioinformatician's workflow with BLAST.

Quick Start

  • 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/blast and press enter.

  • Download the LATEST version of Grakn.

  • Unzip the downloaded file. (if you use a package installer such as brew, you'll have access to the grakn command 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 the proteins keyspace.

  • 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.

Advanced Usage

Some of the following instructions assume that you have a basic knowledge of writing Python code.

Selecting different sets of target seqeunces

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.

Importing your own protein sequences

If you have already gone through the Quick Start section, first you need to clean the proteins keyspace:

    1. Enter the keyspace via Grakn Console: path-to-grakn-dist-directory(the unzipped folder)/grakn console --keyspace proteins
    1. Remove both the schema definitions and data instances: clean
    1. confirm
    1. 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

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

Run BLAST requests against your own EC2 BLAST Cloud instance

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.py file to:
    • change the url passed to the qblast() method to that of your private cloud instance
    • add username="blast" and password="your instance id" to the parameters passed to qblast()
  • run python3 blast.py

Run BLAST against NCBI BLAST+

Modify the blast.py file to replace the call to qblast() with NcbiblastxCommandline() as instructed by Biopython here.