Skip to content

Commit 4ec40bd

Browse files
Merge pull request #107 from tripal/v2-issue201-blastForms
Some substantial fixes to blast forms but NOT COMPLETELY Fixed
2 parents 5702be3 + 317e531 commit 4ec40bd

27 files changed

+59039
-8
lines changed

Diff for: mkdocs/docs/admin/blast-databases.md

+63
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,66 @@
55

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

8+
## How do I format my blast databases for use with Tripal BLAST?
9+
10+
NCBI Blast+ comes with a program names `makeblastdb` which we will use to format a fasta file into a blast database.
11+
12+
Arguements for makeblastdb command:
13+
14+
- `-dbtype` indicates the type of sequence in the fasta file. It can be either `nucl` or `prot`
15+
- `-parse_seqids` indicates that you want to parse the fasta headers to be used by the blast query program
16+
- `-hash_index` creates an index for faster blast searches
17+
- `-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.
18+
- `-input_type` indicates the type of file you provided to `-in` and it can be either `fasta` or `blastdb`.
19+
- `-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.
20+
- `-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.
21+
22+
### Nucleotide
23+
24+
The command template to create a blast database from a nucleotide fasta file is:
25+
26+
```
27+
makeblastdb -dbtype nucl -parse_seqids -hash_index -in FASTAFILE -input_type fasta -title "Genome Assembly Title with version" -out GENOMEASSEMBLY
28+
```
29+
30+
An example which is actually how the demonstration blast database distributed with this module was created is:
31+
32+
```
33+
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
34+
```
35+
36+
and the output of the command was
37+
38+
> Building a new DB, current time: 03/31/2024 22:10:54
39+
> New DB name: Chlamydomonas_reinhardtii_v5.6
40+
> New DB title: Chlamydomonas reinhardtii v5.6
41+
> Sequence type: Nucleotide
42+
> Keep Linkouts: T
43+
> Keep MBits: T
44+
> Maximum file size: 1000000000B
45+
> Adding sequences from FASTA; added 54 sequences in 1.82259 seconds.
46+
47+
## Protein
48+
49+
The command template to create a blast database from a protein fasta file is:
50+
51+
```
52+
makeblastdb -dbtype prot -parse_seqids -hash_index -in FASTAFILE -input_type fasta -title "Genome Assembly Title with version" -out GENOMEASSEMBLY
53+
```
54+
55+
An example which is actually how the demonstration blast database distributed with this module was created is:
56+
57+
```
58+
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
59+
```
60+
61+
and the output of the command was
62+
63+
> Building a new DB, current time: 03/31/2024 22:38:57
64+
> New DB name: Chlamydomonas_reinhardtii_v5.6_protein
65+
> New DB title: Chlamydomonas reinhardtii v5.6 Protein
66+
> Sequence type: Nucleotide
67+
> Keep Linkouts: T
68+
> Keep MBits: T
69+
> Maximum file size: 1000000000B
70+
> Adding sequences from FASTA; added 19526 sequences in 4.40205 seconds.

Diff for: mkdocs/docs/install/docker-demo.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ git checkout -b my-feature-or-fix
4242
```
4343
4. Build the docker demonstration image.
4444
```
45-
docker build --tag=tripalBlast:local ./
45+
docker build --tag=tripalblast:local ./
4646
```
4747
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.
4848
```
49-
docker run --publish=80:80 -tid --name=tripalBlast --volume=`pwd`:/var/www/drupal/web/modules/contrib/tripal_blast tripalBlast:local
50-
docker exec tripalBlast service postgresql restart
49+
docker run --publish=80:80 -tid --name=tripalblast --volume=`pwd`:/var/www/drupal/web/modules/contrib/tripal_blast tripalblast:local
50+
docker exec tripalblast service postgresql restart
5151
```
5252

5353
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).

Diff for: src/Form/TripalBlastForm.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $query =
210210
$config_query_upload = \Drupal::config('tripal_blast.settings')
211211
->get('tripal_blast_config_upload.allow_query');
212212

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

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

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

270272
//

Diff for: src/Services/TripalBlastJobService.php

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public function jobsGetJobByJobId($job_id) {
247247
$config = \Drupal::service('tripal_blast.database_service')
248248
->getDatabaseConfig($blastjob->target_blastdb);
249249

250+
$job->blastdb = new \stdClass();
250251
$job->blastdb->db_name = $config['name'];
251252
$job->blastdb->db_path = $config['path'];
252253
$job->blastdb->linkout = new \stdClass();

Diff for: src/Services/TripalBlastProgramBlastp.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* @file
4+
* Form definition of BLASTp program.
5+
*/
6+
7+
namespace Drupal\tripal_blast\Services;
8+
9+
use Drupal\tripal_blast\Services\TripalBlastProgramHelper;
10+
11+
/**
12+
* BLASTp program class.
13+
*/
14+
class TripalBlastProgramBlastp {
15+
const BLASTp = 'blastp';
16+
17+
/**
18+
* Advanced field names used - refer to this value when
19+
* validating and submitting fields under advanced options.
20+
*/
21+
public function formFieldNames() {
22+
// Keys match field names used in form definition below.
23+
$field_name_validator = [];
24+
return $field_name_validator;
25+
}
26+
27+
/**
28+
* Adds the BLASTp Advanced Options to the passed in form.
29+
* This form function is meant to be called within another form definition.
30+
*
31+
* @param $blast_cache
32+
* BLAST job history to reference information information contained.
33+
*
34+
* @return array
35+
* Additional form field definitions.
36+
*/
37+
public function formOptions($blast_cache) {
38+
$blast = self::BLASTp;
39+
40+
// Edit and Resubmit functionality.
41+
// We want to pull up the details from a previous blast and fill them in as defaults
42+
// for this blast.
43+
$options = (isset($blast_cache)) ? $blast_cache : [];
44+
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);
45+
46+
$form_alter = [];
47+
48+
return $form_alter;
49+
}
50+
51+
/**
52+
* Map advanced options specific to this program to BLAST keywords.
53+
*
54+
* @param $advanced_field_names
55+
* Values set from form ($form_state).
56+
*
57+
* @return array
58+
* Form values mapped to BLAST keywords.
59+
*/
60+
public function formFieldBlastKey($advanced_field_values) {
61+
return [];
62+
}
63+
}

Diff for: src/Services/TripalBlastProgramBlastx.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* @file
4+
* Form definition of BLASTx program.
5+
*/
6+
7+
namespace Drupal\tripal_blast\Services;
8+
9+
use Drupal\tripal_blast\Services\TripalBlastProgramHelper;
10+
11+
/**
12+
* BLASTx program class.
13+
*/
14+
class TripalBlastProgramBlastx {
15+
const BLASTx = 'blastx';
16+
17+
/**
18+
* Advanced field names used - refer to this value when
19+
* validating and submitting fields under advanced options.
20+
*/
21+
public function formFieldNames() {
22+
// Keys match field names used in form definition below.
23+
$field_name_validator = [];
24+
return $field_name_validator;
25+
}
26+
27+
/**
28+
* Adds the BLASTx Advanced Options to the passed in form.
29+
* This form function is meant to be called within another form definition.
30+
*
31+
* @param $blast_cache
32+
* BLAST job history to reference information information contained.
33+
*
34+
* @return array
35+
* Additional form field definitions.
36+
*/
37+
public function formOptions($blast_cache) {
38+
$blast = self::BLASTx;
39+
40+
// Edit and Resubmit functionality.
41+
// We want to pull up the details from a previous blast and fill them in as defaults
42+
// for this blast.
43+
$options = (isset($blast_cache)) ? $blast_cache : [];
44+
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);
45+
46+
$form_alter = [];
47+
return $form_alter;
48+
}
49+
50+
/**
51+
* Map advanced options specific to this program to BLAST keywords.
52+
*
53+
* @param $advanced_field_names
54+
* Values set from form ($form_state).
55+
*
56+
* @return array
57+
* Form values mapped to BLAST keywords.
58+
*/
59+
public function formFieldBlastKey($advanced_field_values) {
60+
return [];
61+
}
62+
}

Diff for: src/Services/TripalBlastProgramTblastn.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* @file
4+
* Form definition of tBLASTn program.
5+
*/
6+
7+
namespace Drupal\tripal_blast\Services;
8+
9+
use Drupal\tripal_blast\Services\TripalBlastProgramHelper;
10+
11+
/**
12+
* tBLASTn program class.
13+
*/
14+
class TripalBlastProgramTblastn {
15+
const tBLASTn = 'tblastn';
16+
17+
/**
18+
* Advanced field names used - refer to this value when
19+
* validating and submitting fields under advanced options.
20+
*/
21+
public function formFieldNames() {
22+
// Keys match field names used in form definition below.
23+
$field_name_validator = [];
24+
return $field_name_validator;
25+
}
26+
27+
/**
28+
* Adds the tBLASTn Advanced Options to the passed in form.
29+
* This form function is meant to be called within another form definition.
30+
*
31+
* @param $blast_cache
32+
* BLAST job history to reference information information contained.
33+
*
34+
* @return array
35+
* Additional form field definitions.
36+
*/
37+
public function formOptions($blast_cache) {
38+
$blast = self::tBLASTn;
39+
40+
// Edit and Resubmit functionality.
41+
// We want to pull up the details from a previous blast and fill them in as defaults
42+
// for this blast.
43+
$options = (isset($blast_cache)) ? $blast_cache : [];
44+
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);
45+
46+
$form_alter = [];
47+
48+
return $form_alter;
49+
}
50+
51+
/**
52+
* Map advanced options specific to this program to BLAST keywords.
53+
*
54+
* @param $advanced_field_names
55+
* Values set from form ($form_state).
56+
*
57+
* @return array
58+
* Form values mapped to BLAST keywords.
59+
*/
60+
public function formFieldBlastKey($advanced_field_values) {
61+
return [];
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
10108755045
2+
106631889149
3+
11680583722
4+
122348076936
5+
123157600146
6+
133201802923
7+
133495088526
8+
13388237823
9+
141955375240
10+
14436416117
11+
14687958800
12+
148257954821
13+
14972553776
14+
159893002343
15+
17272891335
16+
176626450533
17+
180334159331
18+
192257222211
19+
202836436513
20+
209573540437
21+
21471786988
22+
21930322904
23+
220749827215
24+
222648923514
25+
249497081312
26+
253753000153
27+
254996107652
28+
271782184127
29+
278570533441
30+
282813072951
31+
286405721439
32+
287847679634
33+
29827764759
34+
316168056929
35+
317436949018
36+
32350981650
37+
32526932432
38+
325350046620
39+
340419494324
40+
35518735411
41+
35770766810
42+
367450593917
43+
36831123715
44+
368561127048
45+
374024658030
46+
380330989942
47+
403246447016
48+
411547853319
49+
420767001647
50+
47385183422
51+
63887213144
52+
73359789128
53+
83902513038
54+
85684198425
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)