Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fasta server side
  • Loading branch information
yuj12001 committed Sep 17, 2015
1 parent eae14a2 commit 0f81a93
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions VQI_GenomeBrowser.js
Expand Up @@ -1715,10 +1715,10 @@ function VQI_GenomeBrowser(id, serviceURL) {

fileInput.addEventListener('change', function (e) {
var file = fileInput.files[0];
if (file.name == "hg19.fa.txt") {
if (file.name == "mm9.fa.txt") {
faFile = file;
}
if (file.name == "hg19.fa.fai.txt") {
if (file.name == "mm9.fa.fai.txt") {
var reader = new FileReader();
reader.onload = function (e) {
data = reader.result;
Expand Down
43 changes: 43 additions & 0 deletions dynamic_loading.php
Expand Up @@ -58,6 +58,49 @@
loadTable();
}

function loadFastaData($chrom, $start, $length, $file, $indexFile){

$indexFile = fopen($indexFile, "r");
$indexArray = [];
while (($line = fgets($indexFile))) {
if($line !== ""){

$lineArray = explode("\t", $line);
array_push($indexArray,$lineArray);

}
}
fclose($indexFile);



foreach ($indexArray as $key => $value) {
if ($value[0] == $chrom){
$chromStart = $value[2];
$chromLength = $value[1];
$lineLength = $value[3];
}
}


$lineNum = floor($start/$lineLength); //the line number of the starting bit
$startBit = $chromStart + $lineNum + $start; //starting bit position


$file = new SplFileObject($file);

$file->fseek($startBit);

$resultLine1 = $file->current();
$file->next();
$nextLine2 = $file->current();
$file->next();
$nextLine3 = $file->current();

$composeLine = $resultLine1 . $nextLine2 . $nextLine3;
$returnString = str_replace("\n", "", $composeLine);
return substr($returnString,0,$length);
}


function processData($serviceUrl,$processFileHandle){
Expand Down

0 comments on commit 0f81a93

Please sign in to comment.