Skip to content

Commit

Permalink
Merge pull request #107 from tripal/v2-issue201-blastForms
Browse files Browse the repository at this point in the history
Some substantial fixes to blast forms but NOT COMPLETELY Fixed
  • Loading branch information
laceysanderson authored Apr 1, 2024
2 parents 5702be3 + 317e531 commit 4ec40bd
Show file tree
Hide file tree
Showing 27 changed files with 59,039 additions and 8 deletions.
63 changes: 63 additions & 0 deletions mkdocs/docs/admin/blast-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,66 @@

This documentation is still being developed as this module is being upgraded.

## How do I format my blast databases for use with Tripal BLAST?

NCBI Blast+ comes with a program names `makeblastdb` which we will use to format a fasta file into a blast database.

Arguements for makeblastdb command:

- `-dbtype` indicates the type of sequence in the fasta file. It can be either `nucl` or `prot`
- `-parse_seqids` indicates that you want to parse the fasta headers to be used by the blast query program
- `-hash_index` creates an index for faster blast searches
- `-in FASTAFILE` indicates that the fasta file you replace the token FASTAFILE with should be the input (i.e. the source for the blast database). Note: gzipped fasta is not a supported type for your input file.
- `-input_type` indicates the type of file you provided to `-in` and it can be either `fasta` or `blastdb`.
- `-title` should be a human-readable title describing this blast database. I recommend using the full name of the assembly including the version and the accession if known.
- `-out GENOMEASSEMBLY` will be the filename of the blast database produced not including any file type suffix. The token GENOMEASSEMBLY should be replaced with an alphanumeric string uniquely describing the genome assembly that is the source for the blast database.

### Nucleotide

The command template to create a blast database from a nucleotide fasta file is:

```
makeblastdb -dbtype nucl -parse_seqids -hash_index -in FASTAFILE -input_type fasta -title "Genome Assembly Title with version" -out GENOMEASSEMBLY
```

An example which is actually how the demonstration blast database distributed with this module was created is:

```
makeblastdb -dbtype nucl -parse_seqids -hash_index -in Creinhardtii_281_v5.0.fa -input_type fasta -title "Chlamydomonas reinhardtii v5.6" -out Chlamydomonas_reinhardtii_v5.6
```

and the output of the command was

> Building a new DB, current time: 03/31/2024 22:10:54
> New DB name: Chlamydomonas_reinhardtii_v5.6
> New DB title: Chlamydomonas reinhardtii v5.6
> Sequence type: Nucleotide
> Keep Linkouts: T
> Keep MBits: T
> Maximum file size: 1000000000B
> Adding sequences from FASTA; added 54 sequences in 1.82259 seconds.
## Protein

The command template to create a blast database from a protein fasta file is:

```
makeblastdb -dbtype prot -parse_seqids -hash_index -in FASTAFILE -input_type fasta -title "Genome Assembly Title with version" -out GENOMEASSEMBLY
```

An example which is actually how the demonstration blast database distributed with this module was created is:

```
makeblastdb -dbtype nucl -parse_seqids -hash_index -in Creinhardtii_281_v5.5.protein.fa -input_type fasta -title "Chlamydomonas reinhardtii v5.6 Protein" -out Chlamydomonas_reinhardtii_v5.6_protein
```

and the output of the command was

> Building a new DB, current time: 03/31/2024 22:38:57
> New DB name: Chlamydomonas_reinhardtii_v5.6_protein
> New DB title: Chlamydomonas reinhardtii v5.6 Protein
> Sequence type: Nucleotide
> Keep Linkouts: T
> Keep MBits: T
> Maximum file size: 1000000000B
> Adding sequences from FASTA; added 19526 sequences in 4.40205 seconds.
6 changes: 3 additions & 3 deletions mkdocs/docs/install/docker-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ git checkout -b my-feature-or-fix
```
4. Build the docker demonstration image.
```
docker build --tag=tripalBlast:local ./
docker build --tag=tripalblast:local ./
```
5. Create a container from the previous image in your current directory. The `--volume` part of this command will mount your current directory to the appropriate place inside the container.
```
docker run --publish=80:80 -tid --name=tripalBlast --volume=`pwd`:/var/www/drupal/web/modules/contrib/tripal_blast tripalBlast:local
docker exec tripalBlast service postgresql restart
docker run --publish=80:80 -tid --name=tripalblast --volume=`pwd`:/var/www/drupal/web/modules/contrib/tripal_blast tripalblast:local
docker exec tripalblast service postgresql restart
```

Now you can interact with the Tripal site in your browser in all the same ways you would a regular Tripal site by going to https://localhost and logging in using the [Administrative username and password for the Tripal Docker](https://tripaldoc.readthedocs.io/en/latest/install/docker.html#development-site-information).
Expand Down
6 changes: 4 additions & 2 deletions src/Form/TripalBlastForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $query =
$config_query_upload = \Drupal::config('tripal_blast.settings')
->get('tripal_blast_config_upload.allow_query');

// We don't current support this well so disabling for now.
$is_query_upload_true = $config_query_upload ?? TRUE;
if ($is_query_upload_true) {
if (FALSE) {
// Upload a file as an alternative to enter a query sequence.
$form['#attributes']['enctype'] = 'multipart/form-data';

Expand Down Expand Up @@ -263,8 +264,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $query =
'#default_value' => $defaults['SELECT_DB'],
];

// We don't currently support this well so its being disabled for now.
// Allow target upload - allow target configuration set to TRUE.
if ($config_query_upload) {
if (FALSE) {
$form['#attributes']['enctype'] = 'multipart/form-data';

//
Expand Down
1 change: 1 addition & 0 deletions src/Services/TripalBlastJobService.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public function jobsGetJobByJobId($job_id) {
$config = \Drupal::service('tripal_blast.database_service')
->getDatabaseConfig($blastjob->target_blastdb);

$job->blastdb = new \stdClass();
$job->blastdb->db_name = $config['name'];
$job->blastdb->db_path = $config['path'];
$job->blastdb->linkout = new \stdClass();
Expand Down
63 changes: 63 additions & 0 deletions src/Services/TripalBlastProgramBlastp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @file
* Form definition of BLASTp program.
*/

namespace Drupal\tripal_blast\Services;

use Drupal\tripal_blast\Services\TripalBlastProgramHelper;

/**
* BLASTp program class.
*/
class TripalBlastProgramBlastp {
const BLASTp = 'blastp';

/**
* Advanced field names used - refer to this value when
* validating and submitting fields under advanced options.
*/
public function formFieldNames() {
// Keys match field names used in form definition below.
$field_name_validator = [];
return $field_name_validator;
}

/**
* Adds the BLASTp Advanced Options to the passed in form.
* This form function is meant to be called within another form definition.
*
* @param $blast_cache
* BLAST job history to reference information information contained.
*
* @return array
* Additional form field definitions.
*/
public function formOptions($blast_cache) {
$blast = self::BLASTp;

// Edit and Resubmit functionality.
// We want to pull up the details from a previous blast and fill them in as defaults
// for this blast.
$options = (isset($blast_cache)) ? $blast_cache : [];
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);

$form_alter = [];

return $form_alter;
}

/**
* Map advanced options specific to this program to BLAST keywords.
*
* @param $advanced_field_names
* Values set from form ($form_state).
*
* @return array
* Form values mapped to BLAST keywords.
*/
public function formFieldBlastKey($advanced_field_values) {
return [];
}
}
62 changes: 62 additions & 0 deletions src/Services/TripalBlastProgramBlastx.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* @file
* Form definition of BLASTx program.
*/

namespace Drupal\tripal_blast\Services;

use Drupal\tripal_blast\Services\TripalBlastProgramHelper;

/**
* BLASTx program class.
*/
class TripalBlastProgramBlastx {
const BLASTx = 'blastx';

/**
* Advanced field names used - refer to this value when
* validating and submitting fields under advanced options.
*/
public function formFieldNames() {
// Keys match field names used in form definition below.
$field_name_validator = [];
return $field_name_validator;
}

/**
* Adds the BLASTx Advanced Options to the passed in form.
* This form function is meant to be called within another form definition.
*
* @param $blast_cache
* BLAST job history to reference information information contained.
*
* @return array
* Additional form field definitions.
*/
public function formOptions($blast_cache) {
$blast = self::BLASTx;

// Edit and Resubmit functionality.
// We want to pull up the details from a previous blast and fill them in as defaults
// for this blast.
$options = (isset($blast_cache)) ? $blast_cache : [];
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);

$form_alter = [];
return $form_alter;
}

/**
* Map advanced options specific to this program to BLAST keywords.
*
* @param $advanced_field_names
* Values set from form ($form_state).
*
* @return array
* Form values mapped to BLAST keywords.
*/
public function formFieldBlastKey($advanced_field_values) {
return [];
}
}
63 changes: 63 additions & 0 deletions src/Services/TripalBlastProgramTblastn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @file
* Form definition of tBLASTn program.
*/

namespace Drupal\tripal_blast\Services;

use Drupal\tripal_blast\Services\TripalBlastProgramHelper;

/**
* tBLASTn program class.
*/
class TripalBlastProgramTblastn {
const tBLASTn = 'tblastn';

/**
* Advanced field names used - refer to this value when
* validating and submitting fields under advanced options.
*/
public function formFieldNames() {
// Keys match field names used in form definition below.
$field_name_validator = [];
return $field_name_validator;
}

/**
* Adds the tBLASTn Advanced Options to the passed in form.
* This form function is meant to be called within another form definition.
*
* @param $blast_cache
* BLAST job history to reference information information contained.
*
* @return array
* Additional form field definitions.
*/
public function formOptions($blast_cache) {
$blast = self::tBLASTn;

// Edit and Resubmit functionality.
// We want to pull up the details from a previous blast and fill them in as defaults
// for this blast.
$options = (isset($blast_cache)) ? $blast_cache : [];
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);

$form_alter = [];

return $form_alter;
}

/**
* Map advanced options specific to this program to BLAST keywords.
*
* @param $advanced_field_names
* Values set from form ($form_state).
*
* @return array
* Form values mapped to BLAST keywords.
*/
public function formFieldBlastKey($advanced_field_values) {
return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
10108755045
106631889149
11680583722
122348076936
123157600146
133201802923
133495088526
13388237823
141955375240
14436416117
14687958800
148257954821
14972553776
159893002343
17272891335
176626450533
180334159331
192257222211
202836436513
209573540437
21471786988
21930322904
220749827215
222648923514
249497081312
253753000153
254996107652
271782184127
278570533441
282813072951
286405721439
287847679634
29827764759
316168056929
317436949018
32350981650
32526932432
325350046620
340419494324
35518735411
35770766810
367450593917
36831123715
368561127048
374024658030
380330989942
403246447016
411547853319
420767001647
47385183422
63887213144
73359789128
83902513038
85684198425
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4ec40bd

Please sign in to comment.