示例#1
0
 static function performDNARNAFilter($con, $previousTable, $currentTable, $args)
 {
     if ($args == null || count($args) == 0) {
         return;
     } else {
         if (count($args) != 2) {
             REDLog::writeErrLog("Args for DNA-RNA Filter are incomplete, please have a check");
         }
     }
     TableCreator::createFilterTable($con, $previousTable, $currentTable);
     REDLog::writeInfoLog("Start performing DNA-RNA Filter");
     $dnaVcfTable = $args[0];
     $editingType = $args[1];
     $negativeType = REDTools::getNegativeStrandEditingType($editingType);
     try {
         $num1 = substr($editingType, 0, 1);
         $num2 = substr($negativeType, 0, 1);
         $sqlClause = "insert into {$currentTable} select * from {$previousTable} where exists (select chrom\nfrom {$dnaVcfTable} where ({$dnaVcfTable}.chrom={$previousTable}.chrom and {$dnaVcfTable}.pos={$previousTable}.pos and (\n{$dnaVcfTable}.ref='{$num1}' or {$dnaVcfTable}.ref='{$num2}')))";
         $v = mysqli_query($con, $sqlClause);
         if (!$v) {
             throw new Exception("Error execute sql clause in performDNARNAFilter");
         }
     } catch (Exception $e) {
         REDLog::writeErrLog($e->getMessage());
     }
     REDLog::writeInfoLog("End performing DNA-RNA Filter");
 }
示例#2
0
 static function performRepeatRegionsFilter($con, $previousTable, $currentTable, $args)
 {
     TableCreator::createFilterTable($con, $previousTable, $currentTable);
     REDLog::writeInfoLog("Start performing Repeat Regions Filter");
     $repeatTable = "repeat_masker";
     try {
         $sqlClause1 = "insert into " . $currentTable . " select * from " . $previousTable . " where not exists (select * from " . $repeatTable . " where (" . $repeatTable . ".chrom= " . $previousTable . ".chrom and  " . $repeatTable . ".begin<=" . $previousTable . ".pos and " . $repeatTable . ".end>=" . $previousTable . ".pos)) ";
         $a = mysqli_query($con, $sqlClause1);
         if (!$a) {
             throw new Exception("Error execute sqlA clause in performRepeatRegionsFilter");
         }
         REDLog::writeInfoLog("Start finding sites in Alu Regions");
         $tempTable = REDTools::getRandomString(10);
         $sqlClause2 = "create temporary table {$tempTable} like {$currentTable}";
         $b = mysqli_query($con, $sqlClause2);
         if (!$b) {
             throw new Exception("Error execute sqlB clause in performRepeatRegionsFilter");
         }
         $sqlClause3 = "insert into  {$tempTable} select * from {$previousTable} where exists (select chrom from {$repeatTable}\nwhere {$repeatTable}.chrom = {$previousTable}.chrom and {$repeatTable}.begin<={$previousTable}.pos and\n{$repeatTable}.end>={$previousTable}.pos and {$repeatTable}.type='SINE/Alu')";
         $c = mysqli_query($con, $sqlClause3);
         if (!$c) {
             throw new Exception("Error execute sqlC clause in performRepeatRegionsFilter");
         }
         $sqlClause4 = "update {$tempTable} set alu='T'";
         $d = mysqli_query($con, $sqlClause4);
         if (!$d) {
             throw new Exception("Error execute sqlD clause in performRepeatRegionsFilter");
         }
         $sqlClause5 = "insert into {$currentTable} select * from {$tempTable}";
         $e = mysqli_query($con, $sqlClause5);
         if (!$e) {
             throw new Exception("Error execute sqlE clause in performRepeatRegionsFilter");
         }
         DatabaseManager::deleteTable($con, $tempTable);
         REDLog::writeInfoLog("End finding sites in Alu Regions");
     } catch (Exception $e) {
         REDLog::writeErrLog($e->getMessage());
     }
     REDLog::writeInfoLog("End performing Repeat Regions Filter");
 }
示例#3
0
 static function performEditingTypeFilter($con, $previousTable, $currentTable, $args)
 {
     REDLog::writeInfoLog('Star executing Editing Type Filter');
     TableCreator::createFilterTable($con, $previousTable, $currentTable);
     $refAlt = $args;
     $refAlt2 = REDTools::getNegativeStrandEditingType($refAlt);
     $sql11 = substr($refAlt, 0, 1);
     $sql12 = substr($refAlt, 1);
     $sql21 = substr($refAlt2, 0, 1);
     $sql22 = substr($refAlt2, 1);
     $sql1 = "insert into " . $currentTable . " select * from " . $previousTable . " WHERE REF='{$sql11}' AND ALT='{$sql12}' AND GT!='0/0'";
     $v = DatabaseManager::insertClause($con, $sql1);
     if (!$v) {
         REDLog::writeErrLog('There is a syntax error for SQL clause:' . $sql1);
     }
     $sql2 = "insert into " . $currentTable . " select * from " . $previousTable . " WHERE REF='{$sql21}' AND ALT='{$sql22}' AND GT!='0/0'";
     $v = DatabaseManager::insertClause($con, $sql2);
     if (!$v) {
         REDLog::writeErrLog('There is a syntax error for SQL clause:' . $sql2);
     }
     REDLog::writeInfoLog('End executing Editing Type Filter');
 }
示例#4
0
<?php

include '../REDTools/REDLog.php';
include '../database/DatabaseManager.php';
include '../database/DatabaseConnect.php';
include '../filters/denovo/SpliceJunctionFilter.php';
include '../database/TableCreator.php';
include '../REDTools/REDTools.php';
include '../REDTools/SiteBean.php';
$con = DatabaseConnect::mysqlConnect();
$args = array("2");
$previousTable = "bj22n_qcfilter_rrfilter";
$currentFilterName = SpliceJunctionFilter::getName();
$currentTable = REDTools::getFirstHalfTableName($previousTable) . $currentFilterName;
SpliceJunctionFilter::performSpliceJunctionFilter($con, $previousTable, $currentTable, $args);
示例#5
0
<?php

include "../REDTools/REDTools.php";
$tableName1 = "1_bj22n_rnavcf_20151117113605am";
$tableName2 = "1_bj22n_rnavcf_etfilter_20151117113905am";
$firstHalf1 = REDTools::getFirstHalfTableName($tableName1);
$firstHalf2 = REDTools::getFirstHalfTableName($tableName2);
echo "{$firstHalf1}";
echo "<hr>";
echo "{$firstHalf2}";
示例#6
0
<?php

include '../REDTools/REDTools.php';
echo REDTools::getNegativeStrandEditingType('TC');
示例#7
0
 static function executeFilters()
 {
     $startInfo = "RNA Editing Detector start\r\n" . "--------------------------\r\n" . "--------------------------\r\n";
     REDLog::writeInfoLog($startInfo);
     $infoPath = "../infoFile";
     if (($lineArray = REDTools::readInfoFile($infoPath)) != false) {
         $con = DatabaseConnect::mysqlConnect();
         $userid = $lineArray[0];
         $rnaVcfName = $lineArray[1];
         $dnaVcfName = $lineArray[2];
         $etArgs = $lineArray[3];
         $qcArray = explode('/', $lineArray[4]);
         $qcArgs = array($qcArray[0], $qcArray[1]);
         $rrArgs = array(0);
         $sjArgs = array($lineArray[5]);
         $ksArgs = array(0);
         $drArgs = array();
         //assignment in DRMode
         $lrArgs = array();
         $storgePath = "G:/Taruca/data/";
         $rnaVcfFilePath = $storgePath . $rnaVcfName;
         $dnaVcfFilePath = $storgePath . $dnaVcfName;
         if ($rnaVcfName !== "null") {
             //denove mode
             //load RNAVcfFile
             $rnaVcfTableNameArray = RNAVCFParser::parseMultiRNAVCFFile($con, $rnaVcfFilePath, $userid);
             if ($dnaVcfName !== "null") {
                 $dnaVcfTableNameArray = DNAVCFParser::parseMultiDNAVCFFile($con, $dnaVcfFilePath, $userid);
             }
             if (count($rnaVcfTableNameArray) != 0) {
                 $i = 0;
                 foreach ($rnaVcfTableNameArray as $rnaVcfTableName) {
                     $etTableName = REDTools::getFirstHalfTableName($rnaVcfTableName) . EditingTypeFilter::getName() . "_" . date("Ymdhisa");
                     EditingTypeFilter::performEditingTypeFilter($con, $rnaVcfTableName, $etTableName, $etArgs);
                     $qcTableName = REDTools::getFirstHalfTableName($etTableName) . QualityControlFilter::getName() . "_" . date("Ymdhisa");
                     QualityControlFilter::performQualityControlFilter($con, $etTableName, $qcTableName, $qcArgs);
                     $rrTableName = REDTools::getFirstHalfTableName($qcTableName) . RepeatRegionsFilter::getName() . "_" . date("Ymdhisa");
                     RepeatRegionsFilter::performRepeatRegionsFilter($con, $qcTableName, $rrTableName, $rrArgs);
                     $sjTableName = REDTools::getFirstHalfTableName($rrTableName) . SpliceJunctionFilter::getName() . "_" . date("Ymdhisa");
                     SpliceJunctionFilter::performSpliceJunctionFilter($con, $rrTableName, $sjTableName, $sjArgs);
                     $ksTableName = REDTools::getFirstHalfTableName($sjTableName) . KnownSNPFilter::getName() . "_" . date("Ymdhisa");
                     KnownSNPFilter::performKnownSNPFilter($con, $sjTableName, $ksTableName, $ksArgs);
                     if ($dnaVcfName == "null") {
                         REDTools::writeTableIntoDb($con, $userid, $ksTableName);
                     } else {
                         if (count($dnaVcfTableNameArray) == count($rnaVcfTableNameArray)) {
                             $drTableName = REDTools::getFirstHalfTableName($ksTableName) . DNARNAFilter::getName() . "_" . date("Ymdhisa");
                             $drArgs[0] = $dnaVcfTableNameArray[$i];
                             $drArgs[1] = $lineArray[6];
                             DNARNAFilter::performDNARNAFilter($con, $ksTableName, $drTableName, $drArgs);
                             $lrTableName = REDTools::getFirstHalfTableName($drTableName) . LikelihoodRateFilter::getName() . "_" . date("Ymdhisa");
                             $lrArgs[0] = $dnaVcfTableNameArray[$i];
                             $lrArgs[1] = $lineArray[7];
                             LikelihoodRateFilter::performLikelihoodRateFilter($con, $drTableName, $lrTableName, $lrArgs);
                             REDTools::writeTableIntoDb($con, $userid, $lrTableName);
                         } else {
                             REDLog::writeErrLog("The num of DNA sample is different from RNA sample, please check your vcf file");
                         }
                     }
                     $i++;
                 }
             } else {
                 REDLog::writeErrLog("There is no rnaVcfTables");
             }
         }
         $endInfo = "------------------------\r\n" . "------------------------\r\n" . "RNA Editing Detector end\r\n";
         REDLog::writeInfoLog("{$endInfo}");
     } else {
         //sleep 10 minute,20s to test
         sleep(20);
         self::executeFilters();
     }
 }
示例#8
0
<?php

include "../REDTools/REDTools.php";
include "../REDTools/REDLog.php";
$dirPath = "../infoFile";
$fileArray = REDTools::readInfoFile($dirPath);
//var_dump($fileArray);
//echo count($fileArray);
echo $fileArray;
示例#9
0
文件: execute.php 项目: Taruca/lib
<?php

include "../database/DatabaseConnect.php";
include "../database/DatabaseManager.php";
include "../database/TableCreator.php";
include "../dataparser/DNAVCFParser.php";
include "../dataparser/RNAVCFParser.php";
include "../filters/denovo/EditingTypeFilter.php";
include "../filters/denovo/KnownSNPFilter.php";
include "../filters/denovo/QualityControlFilter.php";
include "../filters/denovo/RepeatRegionsFilter.php";
include "../filters/denovo/SpliceJunctionFilter.php";
include "../filters/dnaran/DNARNAFilter.php";
include "../filters/dnaran/LikelihoodRateFilter.php";
include "../REDTools/REDLog.php";
include "../REDTools/REDTools.php";
include "../REDTools/SiteBean.php";
$infoPath = "../infoFile";
if (REDTools::readInfoFile($infoPath) != false) {
} else {
}
示例#10
0
<?php

include "../REDTools/REDTools.php";
echo REDTools::getRandomString(10);
echo "<hr>";
echo REDTools::getRandomString(5);
示例#11
0
<?php

include '../database/DatabaseConnect.php';
include '../database/DatabaseManager.php';
include "../REDTools/REDTools.php";
$con = DatabaseConnect::mysqlConnect();
$userid = "1";
$tableName = "testwrite";
REDTools::writeTableIntoDb($con, $userid, $tableName);
echo "end";