diff --git a/app/Http/Controllers/BlastController.php b/app/Http/Controllers/BlastController.php index af5c658d9db7b8c21e1ef60f2c7fdfb5a781fc49..7af10f10d844d2c2710350a6531e3e5a1fcb6a37 100755 --- a/app/Http/Controllers/BlastController.php +++ b/app/Http/Controllers/BlastController.php @@ -73,13 +73,17 @@ class BlastController extends Voyager\VoyagerBaseController /* ** Create the dnafeatures Database + ** (including the feature's type in its name) + ** in format: + ** >featurename_FEATCAT_featurecategory */ $dnafeatures = DnaFeature::all(); // Create an updated fasta file of all DNA features $dnafeaturesfasta = $storagedir . "dnafeatures.fasta"; $FastaFile = fopen($dnafeaturesfasta, 'w'); foreach ($dnafeatures as $dnafeature) { - fwrite($FastaFile, ">$dnafeature->name\n"); + $extendedname = $dnafeature->name . "_FEATCAT_" . $dnafeature->category; + fwrite($FastaFile, ">$extendedname\n"); $toprint = Convert2Fasta($dnafeature->sequence); for ($i=0; $i< count($toprint); $i++) { fwrite($FastaFile, "$toprint[$i]\n"); diff --git a/app/Http/Controllers/lib/Seq.php b/app/Http/Controllers/lib/Seq.php index f7055ed415bbe3524660d08a47161421ab212f54..e626fadd9b47390ea6065b967f7db8c7450fce2a 100755 --- a/app/Http/Controllers/lib/Seq.php +++ b/app/Http/Controllers/lib/Seq.php @@ -35,12 +35,7 @@ function is_dna($seq){ function blast2cirdna($infile, $outfile, $start, $end){ $newtxt = "Start" . "\t" . $start . "\n" . "End" . "\t" . $end . "\n"."\n"; -/* - if(!$input = fopen($infile, "r")){ - echo("ERROR in blast2cirdna: Unable to open data file ". $infile ); - exit; - } -*/ + if(!$output = fopen($outfile, "w")){ echo("ERROR in blast2cirdna: Can't open file " . $outfile . " for writing"); exit; @@ -50,26 +45,36 @@ function blast2cirdna($infile, $outfile, $start, $end){ $txt_string = trim($txt_string, "\n"); //remove whitespace $lines = explode("\n", $txt_string); - $newtxt = "group" . "\n" . "\n"; - fwrite($output, $newtxt); + $newtxt = "group" . "\n" . "\n"; fwrite($output, $newtxt); // For all the lines within the TXT foreach ($lines as $newline) { $line = explode("\t", $newline); - //echo "Block". "\t" . $line["1"]. "\t" . $line["6"]. "\t" . $line["7"] . "\n"; - - $newtxt = "label" . "\n". "Block". "\t"; - fwrite($output, $newtxt); - $newtxt = $line["6"]. "\t" . $line["7"] . "\t" . "3" . "\n"; - fwrite($output, $newtxt); - $newtxt = $line["1"] . "\n"; - fwrite($output, $newtxt); - $newtxt = "endlabel" . "\n" ; - fwrite($output, $newtxt); + $fullname = $line["1"]; + $names = explode("_FEATCAT_", $fullname); + $featname = $names["0"]; + $featcat = $names["1"]; + // set color according to feature category + if ($featcat == "PRO"){ $color = "9"; + } elseif ($featcat == "REG") { $color = "13"; + } elseif ($featcat == "TER") { $color = "9"; + } elseif ($featcat == "SEL") { $color = "1"; + } elseif ($featcat == "REP") { $color = "8"; + } elseif ($featcat == "TAG") { $color = "0"; + } elseif ($featcat == "LOC") { $color = "0"; + } elseif ($featcat == "ORI") { $color = "10"; + } elseif ($featcat == "HYB") { $color = "12"; + } elseif ($featcat == "OTH") { $color = "13"; + } else { $color = "14"; + } + + $newtxt = "label" . "\n". "Block". "\t"; fwrite($output, $newtxt); + $newtxt = $line["6"]. "\t" . $line["7"] . "\t" . $color . "\n"; fwrite($output, $newtxt); + $newtxt = $featname . "\n"; fwrite($output, $newtxt); + $newtxt = "endlabel" . "\n" ; fwrite($output, $newtxt); } - $newtxt = "\n". "endgroup"; - fwrite($output, $newtxt); + $newtxt = "\n". "endgroup"; fwrite($output, $newtxt); fclose($output); }