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

Blasterjs implementation with String #14

Open
alslonik opened this issue Apr 2, 2024 · 0 comments
Open

Blasterjs implementation with String #14

alslonik opened this issue Apr 2, 2024 · 0 comments

Comments

@alslonik
Copy link

alslonik commented Apr 2, 2024

Hi. I am trying to implement blasterjs via String in my web database. Here is my blast output page:

`<?php
// Include necessary files
include_once realpath("../../header.php");

// Your BLAST input parameters
$query = $_POST["query"];
$blast_db = $_POST["blast_db"];
$blast_prog = $_POST["blast_prog"];
$max_hits = $_POST["max_hits"];
$evalue = $_POST["evalue"];
$blast_matrix = $_POST["blast_matrix"];
$blast_filter = $_POST["blast_filter"];

// Define variables
$blast_res = '';
$num_input_seqs = substr_count($query, ">");

// Check for existence of blast_links.json file
$links_hash = [];
$blast_links_file = "$blast_dbs_path/blast_links.json";
if (file_exists($blast_links_file)) {
    $links_json_file = file_get_contents($blast_links_file);
    $links_hash = json_decode($links_json_file, true);
}

// Convert blast_filter checkbox value to "yes" or "no"
$blast_filter = $blast_filter == "on" ? "yes" : "no";

// Construct the BLAST command based on the selected program
if ($blast_prog == "blastn") {
    $blast_cmd = "\"$query\" | $blast_prog -db $blast_db -dust $blast_filter -evalue $evalue -num_descriptions $max_hits -num_alignments $max_hits -html -max_hsps 3";
} elseif ($blast_prog == "tblastn") {
    $blast_cmd = "\"$query\" | $blast_prog -db $blast_db -seg $blast_filter -evalue $evalue -num_descriptions $max_hits -num_alignments $max_hits -html -max_hsps 3";
} elseif (in_array($blast_prog, ["blastp", "blastx", "tblastx"])) {
    $blast_cmd = "\"$query\" | $blast_prog -db $blast_db -seg $blast_filter -evalue $evalue -matrix $blast_matrix -num_descriptions $max_hits -num_alignments $max_hits -html";
}

// Execute BLAST command
$blast_res = shell_exec('printf '.$blast_cmd);
$blast_res = str_replace('<a name=',"<a id=", $blast_res);

// Output HTML structure with BLAST results
echo $blast_res;
?>

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous" />
    <!-- Include any other necessary stylesheets -->
</head>

<body>
    <!-- Your HTML content goes here -->
    <!-- Ensure that you have the necessary elements for Blaster.js -->
    <input type="file" id="blastinput" />
    <div id="blast-multiple-alignments"></div>
    <div id="blast-alignments-table"></div>
    <div id="blast-single-alignment"></div>

    <!-- Include necessary JavaScript files -->
    <script type="text/javascript" src="html2canvas.js"></script>
    <script type="text/javascript" src="blaster.min.js"></script>
    
    <script type="text/javascript">
        // Initialize Blaster.js with the Blast results
        var alignments = "<?php echo $blast_res;?>";
        
        var blasterjs = require("biojs-vis-blasterjs");
        var instance = new blasterjs({
            string: alignments,
            multipleAlignments: "blast-multiple-alignments",
            alignmentsTable: "blast-alignments-table",
            singleAlignment: "blast-single-alignment"
        });
    </script>
</body>

<!-- Include any additional scripts or JavaScript files -->
<!--<script type="text/javascript" src="fruit_genomebase/js/kinetic-v5.1.0.min.js"></script>-->
<!--<script src="fruit_genomebase/js/blast_canvas_graph.js"></script>-->


<!-- Include the output as plain text-->

<div style="margin:20px">
    <a href="blast_input_pomegranate.php"><i class='fas fa-reply' style='color:#229dff'></i> Go back to input</a>
    <a id="download_blast_table" class="float-right" style="cursor:pointer"><i class='far fa-file' style='font-size:24px;color:#229dff'></i> Download result in tabular format</a>
</div>



<?php
// Include necessary files
include_once realpath("$easy_gdb_path/footer.php");
?>

<script>
    // Your JavaScript code goes here, if any
</script>

<style>
    /* Your CSS styles go here, if any */
</style>

`
I do see the text output of blast results, but no output of blasterjs. The files are in the same directory as the blast output.php file. Also, when I put an html test for blasterjs in the same directory, it does work, but with an input file.
Any idea where am I wrong??

Thanks,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant