Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging LegumeFederation Tripal Blast modifications #2

Merged
merged 54 commits into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b613257
Added support for GBRowse links
Jul 23, 2015
8f9caca
Support for using a job id
Jul 23, 2015
17c0469
Fixed option values, tightened up code
Jul 23, 2015
4288955
Brought in line with PeanutBase instance
Jul 23, 2015
22b400f
Added support for GBrowse linkouts
Jul 23, 2015
ea9b56a
Changed path to pages for each blast type
Jul 23, 2015
18a4e2b
Slightly better use of paths
Jul 23, 2015
c3d0095
Reformatted results page, added hit visualization
Jul 23, 2015
e00ace6
fixed alignment coordinates
Jul 23, 2015
7af26be
Modified paths, added support for persistent results by job id
Jul 23, 2015
f03be9e
Tightened up the intro text
Jul 23, 2015
2174700
Added BLAST database path
Jul 23, 2015
f61b6ee
Had to comment-out linkout code for now. Need to resolve Lacey's and …
Jul 23, 2015
9973392
Restored linkout functionality
Jul 24, 2015
714f791
Fixed paths, displays formatter command for debugging purposes
Jul 24, 2015
0616ac9
Intermediate checkin; many repairs to advanced options
ekcannon Jul 28, 2015
94b811a
re-restored linkout functionality
ekcannon Jul 30, 2015
be76f74
tweaks
ekcannon Jul 30, 2015
02b1ea7
Made repairs to GBrowse linkouts
Jul 30, 2015
c51554d
Fixed typo and name of db
Jul 30, 2015
416e71c
Removed all references to gbrowse_track in blastdb table and node
Jul 30, 2015
69b34a6
Restored orginal functionality of GBrowse linkouts
Jul 30, 2015
f2705c7
removed hard-coded example; now uses example set in module configurat…
Jul 30, 2015
65c13e3
Removed debugging code
Jul 30, 2015
cd0b1ce
Cleaned out unused code left over from its life in MaizeGDB
Jul 30, 2015
426cb44
Made the saving of the various module settings variables more explicit
Jul 30, 2015
d986a76
Fixed paths
Jul 30, 2015
6c701fa
removed newline from query def
Jul 30, 2015
5cf53e8
Added .fas as a valid upload file extension
Jul 30, 2015
9d0315b
strips the extension off the blast database path, if any
Jul 31, 2015
364887d
Includes file for custom linkout handling
Jul 31, 2015
9d9a5df
modified linkout code to accommodate custom linkouts
Jul 31, 2015
c574ac7
Added a custom linkout type
Jul 31, 2015
9a2925d
Modified linkout handling to accommodate custom linkouts
Jul 31, 2015
4b8dfd2
Added code to start web services
Aug 17, 2015
283ebb4
initial import
Aug 17, 2015
a828bf3
Added support for qRange/culling_limit option
Aug 17, 2015
5ee0c63
Removed debug statements
Aug 17, 2015
da8dad3
changes in _get_word_size by prateek
prateekgta Aug 27, 2015
b077087
initial import
Aug 27, 2015
9e02c39
Merge branch 'master' into 7.x-1.x
Aug 27, 2015
e917a72
Tidied-up gbrowse link code, added LIS gbrowse links
Sep 17, 2015
5245549
fixed typo
Sep 17, 2015
7e6c5a7
wasn't passing link_id to gbrowse linkout
Sep 17, 2015
7f1d667
Fixed margin error in alignments
Sep 17, 2015
01412d1
added function get_recent_jobs()
Sep 19, 2015
02a2c92
uses get_recent_jobs() to display job list
Sep 19, 2015
0a91799
Uses get_recent_jobs()
Sep 19, 2015
ac9a03e
Completed custom code to support LIS targets
Sep 19, 2015
c8da62b
tweaked recent jobs list
Sep 19, 2015
14d0d67
Added recent jobs list
Sep 19, 2015
f83f264
removed target fasta upload; needs to be turned off/on by option
Sep 19, 2015
d4f3d06
Added explanation for use of 'custom' linkout type
Sep 19, 2015
393b7d2
more refinement in handling of regex
Sep 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 52 additions & 10 deletions api/blast_ui.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ function get_blast_database_options($type) {
* BLAST job (ie: 250)
*/
function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $options, $job_id = NULL) {

$output_file = file_directory_temp() . DIRECTORY_SEPARATOR . $output_filestub . '.blast.asn';
$output_file_xml = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.xml';
$output_file_tsv = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.tsv';
$output_file_html = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.html';

$output_file = file_directory_temp() . DIRECTORY_SEPARATOR . $output_filestub . '.blast.asn';
$output_dir = variable_get('file_public_path', conf_path() . '/files')
. DIRECTORY_SEPARATOR . 'tripal' . DIRECTORY_SEPARATOR . 'tripal_blast';
$output_file_xml = $output_dir . DIRECTORY_SEPARATOR . $output_filestub . '.blast.xml';
$output_file_tsv = $output_dir . DIRECTORY_SEPARATOR . $output_filestub . '.blast.tsv';
$output_file_html = $output_dir . DIRECTORY_SEPARATOR . $output_filestub . '.blast.html';

print "\nExecuting $program\n\n";
print "Query: $query\n";
Expand All @@ -123,11 +123,15 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op

// Allow administrators to use an absolute path for these commands.
// Defaults to using $PATH.
$blast_path = variable_get('blast_path', '');
$blast_path = variable_get('blast_path', '');
$blast_threads = variable_get('blast_threads', '');

$program = $blast_path . $program;
$blast_formatter_command = $blast_path . 'blast_formatter';
// Strip the extension off the BLAST target
$database = preg_replace("/(.*)\.[pn]\w\w/", '$1', $database);

// The executables:
$program = $blast_path . $program;
$blast_formatter_command = $blast_path . 'blast_formatter';

$blast_cmd = "$program -query '$query' -db '$database' -out '$output_file' -outfmt=11";
if (!empty($options)) {
Expand Down Expand Up @@ -155,7 +159,9 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
print "\nGenerating additional download formats...\n";

print "\tXML\n";
system("$blast_formatter_command -archive $output_file -outfmt 5 -out $output_file_xml");
$format_cmd = "$blast_formatter_command -archive $output_file -outfmt 5 -out $output_file_xml";
print "\nExecuting $format_cmd\n\n";
system($format_cmd);
if(!file_exists($output_file_xml)) {
tripal_report_error(
'blast_ui',
Expand Down Expand Up @@ -274,3 +280,39 @@ function get_blastdb_linkout_regex($node, $options = array()) {

return $regex;
}


function get_recent_jobs() {
$html = '';

$sid = session_id();
$jobs = $_SESSION['all_jobs'][$sid];

// Remove jobs older than 48 hours
foreach ($jobs as $job_id => $job) {
if ($diff = abs(time() - strtotime($job['date'])) > 172800) {
unset($jobs[$job_id]);
}
}
$_SESSION['all_jobs'][$sid] = $jobs;

if (count($jobs) > 0) {
$html = "
<h3><strong> Recent Jobs </h3>
<dl>";

foreach (array_reverse($jobs) as $job) {
$q_def = !isset($job['query_defs'][0]) ? "Query" : $job['query_defs'][0];
$html .= "
<dd>
<a href='" . "../../" . $job['job_output_url'] ."'>
$q_def X " . $job['target'] . ' (' . $job['program'] . ') - ' . $job['date'] . "
</a>
</dd>";
}
$html .= "
</dl>";
}

return $html;
}
3 changes: 2 additions & 1 deletion blast_ui.install
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ function blast_ui_schema(){
'default' => 'link'
),
),

'indexes' => array(
'name' => array('name'),
),

'primary key' => array('nid'),
'unique keys' => array(
'nid' => array('nid'),
),
);

return $schema;

}

/**
Expand Down
67 changes: 26 additions & 41 deletions blast_ui.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
require_once 'includes/blast_ui.form_common.inc';
require_once 'includes/blast_ui.form_advanced_options.inc';
// NOTE: The forms themeselves are included using hook_menu to ensure they
// are only inlcuded when needed.
// are only included when needed.

// BLAST DB Node functionality
require_once 'includes/blast_ui.node.inc';

// BLAST Link-out functionality.
require_once 'includes/blast_ui.linkouts.inc';
include_once('includes/blast_ui.custom.inc');

// Functions specific to themeing (ie: preprocess)
require_once 'theme/blast_ui.theme.inc';
Expand Down Expand Up @@ -219,7 +220,7 @@ function show_blast_output($job_id) {
// BLAST is in the queue, running or complete in order to determine what to show the user
//decode the job_id
$job_id = base64_decode($job_id);
$job = tripal_get_job($job_id);
$job = tripal_get_job($job_id);

// 1) Job is in the Queue
if ($job->start_time === NULL AND $job->end_time == NULL) {
Expand Down Expand Up @@ -252,50 +253,15 @@ function show_blast_output($job_id) {
*
*/
function ajax_blast_ui_example_sequence_callback($form, $form_state) {

// First, set a default example sequence in case administrators have not yet
// bothered to set their own.
$sequence_type = $form_state['values']['query_type'];
if ($sequence_type == 'nucleotide') {
$default_example_sequence = '>partial lipoxygenase Glyma15g03040
TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
$default_example_sequence = variable_get('blast_ui_nucleotide_example_sequence', 'sample');
}
elseif ($sequence_type == 'protein') {
$default_example_sequence = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
$default_example_sequence = variable_get('blast_ui_protein_example_sequence', 'sample');
}
else {
$default_example_sequence = '';
$default_example_sequence = 'unknown query type';
}

// If the Show Example checkbox is true then put the example in the textfield
Expand All @@ -313,5 +279,24 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
}

return $form['query']['FASTA'];
}


}
/**
* Enable web services API
*
* @param $owner
*
* @param $api
*
* @return $result
*
*/
function blast_ui_ctools_plugin_api($owner, $api) {
if ($owner == 'services' && $api == 'services') {
return array(
'version' => 3,
'file' => 'includes/blast_ui.services.inc'
);
}
}
2 changes: 1 addition & 1 deletion includes/blast_ui.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function blast_ui_admin_form_validate($form, &$form_state) {
*
*/
function blast_ui_admin_form_submit($form, $form_state) {

variable_set('blast_path', $form_state['values']['blast_path']);
variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
variable_set('blast_threads', $form_state['values']['blast_threads']);
variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
Expand Down
129 changes: 129 additions & 0 deletions includes/blast_ui.custom.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/*
* customized for PeanutBase
*
*/

function tripal_custom_generate_linkout($url_prefix, $hit, $info, $options = array()) {
// uncomment to see contents of hit object
//echo "hit:<pre>";var_dump($hit);echo "</pre>";
// uncomment to see contents of info object
//echo "info:<pre>";var_dump($info);echo "</pre>";

$url = false;
$hit_name = $hit->{'Hit_def'};
//echo "hit name: $hit_name ... ";

if ($info['Target'] == 'All genomes') {
// default regex
$regex = "/^\w+\.(\S+).*/";

if (preg_match('/^aradu/', $hit_name) == 1) {
$blastdb_name = 'PeanutBase_aradu_gbrowse';
}
else if (preg_match('/^araip/', $hit_name) == 1) {
$blastdb_name = 'PeanutBase_araip_gbrowse';
}
else if (preg_match('/^cajca/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_cajca_gbrowse';
}
else if (preg_match('/^cicar/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_cicar_gbrowse';
}
else if (preg_match('/^glyma/', $hit_name) == 1) {
$blastdb_name = 'SoyBase_glyma_gbrowse';
}
else if (preg_match('/^lotja/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_lotja_gbrowse';
}
else if (preg_match('/^medtr/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_medtr_gbrowse';
}
else if (preg_match('/^phavu/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_phavu_gbrowse';
}
else if (preg_match('/^vigra/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_vigra_gbrowse';
}
else {
// Don't know what to do with this hit
drupal_set_message("Don't know how to create GBrowse linkout for $hit_name", 'error');
}

$hit_name = preg_replace($regex, '$1', $hit_name);
$hit->{'linkout_id'} = $hit_name;
if ($blastdb_info = tripal_custom_getBLASTdbinfo($blastdb_name)) {
//echo "generate gbrowse link with " . $blastdb_info['urlprefix'] . " $hit<br>";
$url = tripal_blast_generate_linkout_gbrowse($blastdb_info['urlprefix'], $hit, $info, $options);
}
}//handle All genomes BLAST target

else {
// default regex:
$regex = "/^\w+\.(\S+)/";

if (preg_match('/^aradu/', $hit_name) == 1) {
$blastdb_name = 'PeanutBase_aradu_gene';
}
else if (preg_match('/^araip/', $hit_name) == 1) {
$blastdb_name = 'PeanutBase_araip_gene';
}
else if (preg_match('/^cajca/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_cajca_gene';
}
else if (preg_match('/^cicar/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_cicar_gene';
}
else if (preg_match('/^glyma/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_glyma_gene';
if (preg_match("/^\w+\.(\S+)\.p/", $hit_name)) {
//glyma protein
$regex = "/^\w+\.(\S+)\.p/";
}
}
else if (preg_match('/^lotja/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_lotja_gene';
}
else if (preg_match('/^medtr/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_medtr_gene';
}
else if (preg_match('/^phavu/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_phavu_gene';
}
else if (preg_match('/^vigra/', $hit_name) == 1) {
$blastdb_name = 'LegumeInfo_vigra_gene';
}
else {
// Don't know what to do with this hit
drupal_set_message("Don't know how to create linkout for $hit_name", 'error');
}

$hit_name = preg_match($regex, $hit_name, $matches);
//echo "<br>Using $regex, found matches:<pre>" . var_dump($matches);echo "</pre>";
//echo "<br>Use [" . $matches[1] . "]<br>";
$hit->{'linkout_id'} = $matches[1];
//echo "look for gene link for $blastdb_name with " . $hit->{'linkout_id'} . "<br>";
if ($blastdb_info = tripal_custom_getBLASTdbinfo($blastdb_name)) {
//echo "generate gbrowse link with " . $blastdb_info['urlprefix'] . " $hit<br>";
$url = tripal_blast_generate_linkout_link($blastdb_info['urlprefix'], $hit, $info, $options);
}
}
return $url;
}


function tripal_custom_getBLASTdbinfo($blastdb_name) {
$sql = "
SELECT urlprefix
FROM {db} WHERE name='$blastdb_name'";
//echo "$sql<br>";
if ($res = chado_query($sql)) {
if ($row=$res->fetchObject()) {
return array(
'urlprefix' => $row->urlprefix,
);
}
}

return false;
}//tripal_custom_getBLASTdbinfo
Loading