fechaPagina(); exit; } verGetPost(array("mtg")); if (!$mtg){ /* */ $mtgs = $genopar->obtemMtgs(); $genopar->abrePagina("Contig Annotation Page"); $genopar->abreForm(); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "Assembly: "; echo ""; $genopar->select("mtg", $mtgs, "","", TRUE); echo "
"; $genopar->submit(); echo "
"; $genopar->fechaForm(); $genopar->fechaPagina(); } $orfWidth=50; $orfHeight=10; $escala=1; $minSize=''; $size=''; $reverse=''; $showInvalid=''; $showQual=''; $start=''; $end=''; $showTable=''; $geraFrames=''; $showClones=''; $COGcolors=''; verGetPost(array( "processa", "contig", "start", "end", "reverse", "COGcolors", "showInvalid", "zoom", "showQual", "geraFrames", "showTable", "kb", "showClones", "orfWidth", "orfHeight", "escala", "startCodon", "minSize" ) ); if (strlen($UserAuth_group)!=2) $table='FP'; else $table= $UserAuth_group; if (!$minSize) $minSize = 100; $genopar->abrePagina("Contig Annotation Page [$mtg]"); echo ' '; $genopar->abreBanco(); $zoom=''; $kb=''; if ($geraFrames == '') $geraFrames = 0; if (!$processa) $geraFrames = 1; if ($showInvalid == '') $showInvalid=0; if ($reverse == '') $reverse = 0; if ($COGcolors == '') $COGcolors = 0; if ($zoom == '' or $zoom<1 or $zoom>19) $zoom=10; $n= $genopar->queryBanco("SELECT id as contig, tam FROM contig WHERE idMontagem='$mtg' ORDER BY id"); $contig_lab= array(); while ($lin= $genopar->getArray()){ array_push($contig_lab, $lin['contig']); $contigs[$lin['contig']]=$lin['tam']; } // $n= $genopar->queryBanco('select contig_num, bp_untrim from contigs where bp_trim>0 and qual_med>20 order by contig_num'); // // $contigs= array(); // while ($lin= $genopar->getArray()) // $contigs[$lin['contig_num']]=$lin['tam']; $kbArray = array(1,5,10,20,50,100); $owArray = array(50,100, 150, 200, 300); $ohArray = array(10,20,50); echo '

'; echo '

'; $genopar->input("mtg", "hidden", $mtg); echo " "; if ($processa=='Fasta'){ if ($start == "" or $start < 1) $start= 1; elseif ($start > $contigs[$contig]) $start = $contigs[$contig]; if (($end == "") or ($end > $contigs[$contig])) $end = $contigs[$contig]; if ($start < $end && $reverse){ $tmp = $end; $end = $start; $start = $tmp; }elseif($start > $end && !$reverse){ $tmp = $end; $end = $start; $start = $tmp; } } echo "
Contig: Start: End: Contig's Table
"; echo "
Graphic
Find ORF's
Sequence

"; echo '
'; ######### AVISO SOBRE BLAST $blastAtualizado = $genopar->queryBanco(" SELECT max(idEdicao) FROM edicaoORF WHERE idMontagem='$mtg' AND BLAST_atualizado=0"); $blastAtualizado = $genopar->getArray(); if ($blastAtualizado[0]){ $updateBlastLink = "javascript:popup(\"outOfDateBLASTs.php?mtg=$mtg&popup=1\")"; echo "

WARNING: There are out of date BLAST reports for this assembly. (update)

"; } echo '

'; if ($processa == '') tabelaContigs($genopar, $mtg); if ($processa=='Graphic'){ $ctgLength = $contigs[$contig]; $toSplitSize = 100000; if ($kb != '') $kb *= 1000; else $kb = 0; if ($start == '') $ini = 0; else $ini = $start; if ($end == '') $fim = $ctgLength; else $fim = $end; echo "
Statistics
"; tabelaEstatistica($genopar, $mtg, $contig, $ini, $fim, $COGcolors); echo "
"; if ($fim - $ini > $toSplitSize){ $stop = $fim; $split = 1; // $i = 0; for( $regionStart = $ini, $regionEnd = $ini + $toSplitSize -1; $regionStart < $stop; $regionStart += $toSplitSize, $regionEnd += $toSplitSize ){ if ($regionEnd > $fim) $regionEnd = $fim; $imgSrc = geraSingleGraphAnnot($mtg,$contig,$regionStart,$regionEnd,"",$zoom,$geraFrames,$showInvalid, $showQual, $showClones, $COGcolors, $kb); echo "

"; echo ""; echo "

"; ob_flush(); preg_match("/img\.(.*)\.[a-z]{3}$/", $imgSrc, $matches); $common = $matches[1]; $areaFile_name = "tmp/area.$common"; if (is_readable($areaFile_name)){ $areaFile = fopen($areaFile_name, 'r'); while (!feof($areaFile)){ $line = fgets($areaFile, 4096); echo "$line\n"; if (preg_match("/TITLE/i", $line) && $showTable){ $array = preg_split("/'/", $line); $str = $array[1]; $info = preg_split("/
/", $str); $i = $info[0]; foreach ($info as $data){ if ($data == '') continue; if (preg_match("/<..?>/", $data)){ $split = preg_split("/<..?>/",$data); $key = $split[1]; $value = $split[2]; }else{ $key = 'Gene Id'; $value = $data; } $tbl[$i][$key] = trim($value); $keys[$key] = 1; } $i++; } } fclose($areaFile); } } }else{ $imgSrc = geraSingleGraphAnnot($mtg,$contig,$ini,$fim,"",$zoom,$geraFrames,$showInvalid, $showQual, $showClones, $COGcolors, $kb); echo "

"; echo ""; echo "

"; preg_match("/img\.(.*)\.[a-z]{3}$/", $imgSrc, $matches); $common = $matches[1]; $areaFile_name = "tmp/area.$common"; if (is_readable($areaFile_name)){ $areaFile = fopen($areaFile_name, 'r'); // $i = 0; while (!feof($areaFile)){ $line = fgets($areaFile, 4096); echo "$line\n"; if (preg_match("/TITLE/i", $line) && $showTable){ $array = preg_split("/'/", $line); $str = $array[1]; $info = preg_split("/
/", $str); $i = $info[0]; foreach ($info as $data){ if ($data == '') continue; if (preg_match("/<..?>/", $data)){ $split = preg_split("/<..?>/",$data); $key = $split[1]; $value = $split[2]; }else{ $key = 'Gene Id'; $value = $data; } $tbl[$i][$key] = trim($value); $keys[$key] = 1; } $i++; } } fclose($areaFile); } } echo ''; echo ""; if ($showTable && count($keys) > 0){ echo '
'; echo ' '; echo ''; echo ''; echo ""; foreach ($keys as $k => $v) echo ""; echo ''; echo ''; echo ''; $color = '#CCCCEE'; // for ($i=0; $i $dados){ echo ""; echo ""; foreach ($keys as $k => $v) if ($k == 'ORF'){ $link = "anotacaoORF.php?processa=Search&mtg=$mtg&id=".$tbl[$i][$k]."&zoom=$zoom&geraFrames=$geraFrames&use_cog=$COGcolors"; echo ""; }else echo ""; echo ''; if ($color == '#CCCCEE') $color = '#DDDDFF'; else $color = '#CCCCEE'; } echo ''; echo '
"; $genopar->input("all", "checkbox", "on", "onClick=\"CheckAll(); return true;\""); echo "$k
"; $genopar->input("ORF".$tbl[$i]['ORF'], "checkbox", "ORF".$tbl[$i]['ORF']); echo "".$tbl[$i][$k]."".$tbl[$i][$k]."
'; echo ''; $col = count($keys) + 1; echo " "; echo '
FASTA: nt - aa
ORF Eraser
ORF Invalider

'; ?>
$end) $reverse= 1; if ( !(is_readable($fcontig)) ) $genopar->error("

Não foi possível ler contig do arquivo: $fcontig"); $file = fopen($fcontig, 'r'); $header = trim(fgets($file, 4096)); $header .= " [$start..$end]\n"; $SEQ=''; for ($linha= 1; !feof($file); $linhas++){ $line = fgets($file, 4096); $SEQ.= trim($line); } if ($reverse){ $size = $start-$end+1; $seq = strtoupper(substr($SEQ,$end-1,$size)); $seq = strrev($seq); $seq = str_replace(array('A','C','G','T',1,2,3,4), array(1,2,3,4,'T','G','C','A'), $seq); }else{ $size = $end-$start+1; $seq= strtoupper(substr($SEQ,$start-1,$size)); } $seqn=""; $cols = 80; for($i=0;$i'; $rows=10; echo ($reverse?"Reverse Complement ":"")."Nucleotide Sequence: ($size pb)


"; } elseif ($processa=='GenBank'){ if ($start == '') $ini = 0; else $ini = $start; if ($end == '') $fim = -1; else $fim = $end; $fcontig = "../Fasta/$mtg/Contigs/n/Contig".$contig.".fas"; $GBfile = "tmp/Contig".$contig."_".$mtg.".gbk"; system("perl geraGenBankFile.pl ".$genopar->MySQL_Default_DBname." $mtg $contig $ini $fim $fcontig $GBfile"); if (is_readable($fcontig)){ $file = fopen($GBfile, 'r'); if ($file){ echo ""; } } }elseif ($processa=='Find'){ if (!$start || !$end){ $genopar->error('You must specify a region to search the ORF\'s'); } if (count($startCodon) < 1){ $genopar->error('You must specify at least one start codon.'); } $allStartCodons = join("|", $startCodon); $ctgFile = "../Fasta/$mtg/Contigs/n/Contig".$contig.".fas"; $cmd = "cd ../autoAnnot && perl findAllORF.pl $ctgFile '$allStartCodons' $minSize $start $end"; system($cmd); $orfsOutDir = "../Fasta/$mtg/ORFs"; $genopar->queryBanco("select max(id) from orf where idMontagem='$mtg' and contigId='$contig'"); $row = $genopar->getArray(); $lastOrfIndex = substr($row[0], -4); if (!$lastOrfIndex){ $lastOrfIndex = "0000"; } system("cd ../autoAnnot && perl separaFastaGenes.pl ".$genopar->MySQL_Default_DBname." $mtg genes.fas $contig $orfsOutDir $lastOrfIndex"); system("cd ../autoAnnot && perl rodaRBSfinder.pl ".$genopar->MySQL_Default_DBname." $mtg $ctgFile genes.predict $lastOrfIndex"); $editor = $UserAuth_username; $genopar->queryBanco("SELECT id FROM orf WHERE idMontagem='$mtg' and contigId=$contig and id > '$contig.$lastOrfIndex'"); $query = 'INSERT INTO edicaoORF VALUES '; while($row = $genopar->getArray()){ $orfId = $row[0]; // Inserir informacao de BLAST desatualizado $query .= "('$mtg', '$orfId', '$editor', CURRENT_DATE (), 0, ''),"; } $query = preg_replace('/\),$/', ')', $query); $genopar->queryBanco($query); system("rm tmp/*\.$mtg\.$contig\.*"); ?> fechaPagina(); function complement($nt){ switch ($nt){ case 'A': case 'a': return 'T'; case 'T'; case 't': return 'A'; case 'C': case 'c': return 'G'; case 'G': case 'g': return 'C'; } return $nt; } function tabelaEstatistica($genopar, $mtg, $contig, $ini, $fim, $COGcolor){ $size = $fim - $ini + 1; $rRNA=0; $ORF = array( 'Total' => 0, 'Valid' => 0, 'Pending' => 0, 'Hypothetical' => 0, 'Conserved Hypothetical' => 0 ); $q = " SELECT a.id, a.validation, v.status FROM orf o, anotacao a, validation v WHERE o.idMontagem='$mtg' AND a.idMontagem='$mtg' AND o.contigId='$contig' AND o.id=a.id AND a.validation=v.code AND a.validation>0 AND o.start>=$ini AND o.start<=$fim AND o.end<=$fim AND o.end>=$ini "; $n = $genopar->queryBanco($q); $ORF['Total'] = $n; while ($lin = $genopar->getArray()){ $ORF[$lin['status']]++; } $basesCount = array('A' => 0,'C' => 0,'T' => 0,'G' => 0); $fcontig="../Fasta/$mtg/Contigs/n/Contig".$contig.".fas"; if ( !(is_readable($fcontig)) ) $genopar->error("

N�o foi poss�vel ler contig do arquivo: $fcontig"); $file = fopen($fcontig, 'r'); $line = fgets($file, 4096); #Eliminar primeira linha for ($linha= 1; !feof($file); $linhas++){ $line = trim(fgets($file, 4096)); $seq .= $line; } if (!$ini) $ini++; $seq = substr($seq, $ini-1, $size); $windowSize = 100000; $arrayPartialSeqs = str_split($seq, $windowSize); foreach($arrayPartialSeqs as $partialSeq){ $bases = str_split($partialSeq); foreach ($bases as $b){ $b = strtoupper($b); if ($b=='A' || $b=='C' || $b=='G' || $b=='T') $basesCount[$b]++; } } $gc = (($basesCount['C'] + $basesCount['G'])/$size * 100)."%"; $q = " SELECT count(tRNAnum) as n FROM tRNA WHERE idMontagem='$mtg' AND contigId='$contig' "; $n = $genopar->queryBanco($q); $lin = $genopar->getArray(); $tRNA = $lin['n']; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "Contig #$contig"; echo "
"; echo "Size"; echo ""; echo $size." bp"; echo ""; echo "Annotated ORF's"; echo ""; echo "Additional Information"; echo "
"; echo "Bases"; echo ""; echo "A: "; echo $basesCount['A']; echo ""; echo "C: "; echo $basesCount['C']; echo ""; echo "Valid: "; echo $ORF['Valid']; echo ""; echo "Pending: "; echo $ORF['Pending']; echo ""; echo "tRNAs: "; echo "$tRNA"; echo "
"; echo "G: "; echo $basesCount['G']; echo ""; echo "T: "; echo $basesCount['T']; echo ""; echo "Hypothetical: "; echo $ORF['Hypothetical']; echo ""; echo "Conserved Hyp.: "; echo $ORF['Conserved Hypothetical']; echo ""; echo "rRNAs: "; echo "$rRNA"; echo "
"; echo "GC%"; echo ""; echo number_format($gc,2,",",",")."%"; echo ""; echo "Total: "; echo $ORF['Total']; echo ""; echo "Colors Code"; echo "
"; } function tabelaContigs($genopar, $mtg){ $genopar->abreBanco(); $q = " SELECT c.id, c.tam, count(a.id) as ORFs FROM contig c, orf o, anotacao a WHERE c.idMontagem='$mtg' AND o.idMontagem=c.idMontagem AND a.idMontagem=o.idMontagem AND c.id = o.contigId AND o.id = a.id GROUP BY o.contigId "; $n = $genopar->queryBanco($q); if ($n > 0){ while ($lin = $genopar->getArray(MYSQL_ASSOC)){ $contig[$lin['id']] = $lin; $contig[$lin['id']]['tRNAs'] = 0; $contig[$lin['id']]['rRNAs'] = 0; } $q = " SELECT contigId as id, count(tRNAnum) as n FROM tRNA WHERE idMontagem='$mtg' GROUP BY contigId "; $genopar->queryBanco($q); while ($lin = $genopar->getArray()) $contig[$lin['id']]['tRNAs'] = $lin['n']; echo "

'$mtg' Assembly Contigs

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $color[0] = '#CCCCEE'; $color[1] = '#DDDDFF'; $i=0; echo ""; foreach($contig as $id => $info){ $contigLink = "index.php?mtg=$mtg&contig=$id&geraFrames=1&processa=Graphic"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; echo "
Contig IdSizeTotal ORF'stRNA'srRNA's
$id".$info['tam']."".$info['ORFs']."".$info['tRNAs']."".$info['rRNAs']."
"; } } ?>