コード例 #1
0
 public function action_add()
 {
     $community = $this->request->param('id');
     if (!$community) {
         $this->request->redirect(URL::base() . 'tournament');
     }
     $view = View::factory('tournament_add');
     $view->community = com_from_id($community);
     $view->available_maps = get_maps();
     /*
     $view->refs = '';
     $view->maps = '';
     */
     $view->description = '';
     $view->exclusive = '';
     if ($_POST) {
         $refs = array();
         $refCount = $_POST['refCount'];
         for ($i = 1; $i <= $refCount; $i++) {
             array_push($refs, $_POST['ref' . $i]);
         }
         $ref_ids = array();
         foreach ($refs as $ref) {
             if (!id_from_name($ref)) {
                 array_push($this->template->errors, "Could not find user: "******"You are not the admin of this community.");
         }
         if (empty($this->template->errors)) {
             //DB::insert('tournies', array('community','admin','description','exclusive'))->values(array($community,$this->user,$description,$exclusive))->execute();
             $this->request->redirect("/tournament?success");
         } else {
             $view->description = $description;
             $view->exclusive = $exclusive;
         }
     }
     $this->template->content = $view;
 }
コード例 #2
0
ファイル: cache.php プロジェクト: BackupTheBerlios/k4bb-svn
 /**
  * Cache all of the MAP's
  */
 function cache_maps(&$cache, &$request)
 {
     $cache['maps'] = get_maps($request['dba']);
 }
コード例 #3
0
ファイル: editdata.php プロジェクト: Procxl/libraries
 $mapstr = "";
 $allmol = explode("\$MOL\r\n", $saferxn);
 $header = $allmol[0];
 // get the fingerprint dictionary
 $fpdefqstr = "SELECT fp_id, fpdef FROM {$fpdeftable};";
 $fpdefresult = mysql_query($fpdefqstr) or die("Could not get fingerprint definition!");
 $i = -1;
 $n_dict = 0;
 $fpdef = array();
 while ($fpdefline = mysql_fetch_array($fpdefresult, MYSQL_ASSOC)) {
     $i++;
     $n_dict++;
     $fpdef[$i] = $fpdefline["fpdef"];
 }
 mysql_free_result($fpdefresult);
 $mapstr = get_maps($saferxn);
 // delete old rxnfgb record first
 $qstr = "DELETE FROM {$rxnfgbtable} WHERE rxn_id = {$rxn_id}";
 $result = mysql_query($qstr);
 $err = mysql_errno();
 if ($err != 0) {
     echo "<br />Action failed (#11/{$err}: " . mysql_error() . ")<br />\n";
     $errorcount++;
 }
 #else { echo "."; }
 // delete old rxncfp record first
 $qstr = "DELETE FROM {$rxncfptable} WHERE rxn_id = {$rxn_id}";
 $result = mysql_query($qstr);
 $err = mysql_errno();
 if ($err != 0) {
     echo "<br />Action failed (#12/{$err}: " . mysql_error() . ")<br />\n";
コード例 #4
0
ファイル: common.php プロジェクト: BackupTheBerlios/k4bb
     * Get ALL of the custom user profile fields
     */
    $cache[PROFILEFIELDS] = array();
    $result =& $_DBA->executeQuery("SELECT * FROM " . PROFILEFIELDS);
    while ($result->next()) {
        $temp = $result->current();
        $cache[PROFILEFIELDS][$temp['name']] = $temp;
        $cache[PROFILEFIELDS][$temp['name']]['html'] = format_profilefield($temp);
        /* Add the extra values onto the end of the userinfo query params variable */
        $query_params['userinfo'] .= ', ui.' . $temp['name'] . ' AS ' . $temp['name'];
    }
    $result->freeResult();
    /* Memory saving */
    unset($result);
    /* Get the MAP's */
    $cache[MAPS] = get_maps();
    /* Create the cache file */
    DBCache::createCache($cache, CACHE_FILE);
} else {
    /* Include the cache file */
    include_once CACHE_FILE;
    if (!isset($cache) || !is_array($cache) || empty($cache)) {
        compile_error('The cache array does not exist or it is empty.', __FILE__, __LINE__);
    }
    /* Add the extra values onto the end of the userinfo query params variable */
    foreach ($cache[PROFILEFIELDS] as $field) {
        $query_params['userinfo'] .= ', ui.' . $field['name'] . ' AS ' . $field['name'];
    }
}
/**
 * Should we rewrite the email cache file? 
コード例 #5
0
ファイル: games.php プロジェクト: ECP-Black/ECP
function admin_games_maps()
{
    $tpl = new smarty();
    $tpl->assign('games', get_games_form());
    $tpl->assign('maps', get_maps());
    ob_start();
    $tpl->display(DESIGN . '/tpl/admin/maps.html');
    $content = ob_get_contents();
    ob_end_clean();
    main_content(MAPS, $content, '', 1);
}
コード例 #6
0
ファイル: rxnfunct.php プロジェクト: Procxl/libraries
function matchrxn($qrxn, $crxn, $cmaps, $options)
{
    global $use_cmmmsrv;
    global $ostype;
    global $MATCHMOL;
    global $n_labels;
    global $n_maps;
    global $map_list;
    global $debug;
    $result = TRUE;
    $rxndescr = analyze_rxnfile($qrxn);
    $nqrmol = get_nrmol($rxndescr);
    $nqpmol = get_npmol($rxndescr);
    $rxndescr = analyze_rxnfile($crxn);
    $ncrmol = get_nrmol($rxndescr);
    $ncpmol = get_npmol($rxndescr);
    $optstr = $options;
    if ($nqrmol == 0 && $ncpmol == 0) {
        $result = FALSE;
    }
    // some initial check
    if ($nqpmol == 0 && $ncrmol == 0) {
        $result = FALSE;
    }
    if ($result == TRUE) {
        if ($use_cmmmsrv == "y") {
            $separator = "\$\$\$\$";
            $lf = "\n";
        } else {
            $separator = "\\\$\\\$\\\$\\\$";
            if ($ostype == 1) {
                $lf = "\n";
            }
            // Linux
            if ($ostype == 2) {
                $lf = "\r\n";
            }
            // Windows
        }
        $allmol = array();
        $qrmol = array();
        $qpmol = array();
        $crmol = array();
        $cpmol = array();
        $allmol = explode("\$MOL\r\n", $qrxn);
        $header = $allmol[0];
        $label_list = array();
        $map_list = array();
        $n_labels = 0;
        $n_maps = 0;
        $n_qmaps = 0;
        $n_cmaps = 0;
        $qmap_list = array();
        $cmap_list = array();
        if ($nqrmol > 0) {
            for ($i = 0; $i < $nqrmol; $i++) {
                $qrmol[$i] = $allmol[$i + 1];
                $mnum = $i + 1;
                if ($debug > 2) {
                    debug_output("query reactant no. {$mnum}:\n{$qrmol[$i]}\n");
                }
            }
        }
        if ($nqpmol > 0) {
            for ($i = 0; $i < $nqpmol; $i++) {
                $qpmol[$i] = $allmol[$i + 1 + $nqrmol];
                $mnum = $i + 1;
                if ($debug > 2) {
                    debug_output("query product no. {$mnum}:\n{$qpmol[$i]}\n");
                }
            }
        }
        $qmaps = get_maps($qrxn);
        $qmap_list = explode(",", $qmaps);
        $n_qmaps = count($qmap_list);
        if (strlen($qmaps) < 8) {
            $n_qmaps = 0;
        }
        $allmol = "";
        $allmol = explode("\$MOL\r\n", $crxn);
        $header = $allmol[0];
        // reset labels and maps
        $n_maps = 0;
        $map_list = "";
        $n_labels = 0;
        $label_list = "";
        if ($ncrmol > 0) {
            for ($i = 0; $i < $ncrmol; $i++) {
                $crmol[$i] = $allmol[$i + 1];
                $mnum = $i + 1;
                if ($debug > 2) {
                    debug_output("candidate reactant no. {$mnum}:\n{$crmol[$i]}\n");
                }
            }
        }
        if ($ncpmol > 0) {
            for ($i = 0; $i < $ncpmol; $i++) {
                $cpmol[$i] = $allmol[$i + 1 + $ncrmol];
                $mnum = $i + 1;
                if ($debug > 2) {
                    debug_output("candidate product no. {$mnum}:\n{$cpmol[$i]}\n)");
                }
            }
        }
        //echo "<pre>$qrmol[0]\n$qpmol[0]\n\n$crmol[0]\n$cpmol[0]</pre>";
        //$cmaps = get_maps($crxn);    // this is now retrieved from rxnstructable
        $cmap_list = explode(",", $cmaps);
        $n_cmaps = count($cmap_list);
        if (strlen($cmaps) < 8) {
            $n_cmaps = 0;
        }
        // set up and initialize the two match matrices (reactant and product)
        $rmm = array();
        for ($iq = 0; $iq < $nqrmol; $iq++) {
            for ($ic = 0; $ic < $ncrmol; $ic++) {
                $rmm[$iq][$ic] = "0";
            }
        }
        $pmm = array();
        for ($iq = 0; $iq < $nqpmol; $iq++) {
            for ($ic = 0; $ic < $ncpmol; $ic++) {
                $pmm[$iq][$ic] = "0";
            }
        }
        if ($n_qmaps > 0 && $n_cmaps > 0) {
            $optstr .= "n";
        }
        $mmcmd = "{$MATCHMOL} {$optstr} -";
        //============ first match the reactants, if there are any
        if ($nqrmol > 0 && $ncrmol > 0) {
            // assemble the SDF files to be passed to matchmol
            for ($iq = 0; $iq < $nqrmol; $iq++) {
                $qmol = rtrim($qrmol[$iq]);
                $sdf = $qmol . $lf . $separator . $lf;
                for ($ic = 0; $ic < $ncrmol; $ic++) {
                    $cmol = rtrim($crmol[$ic]);
                    $sdf .= $cmol . $lf . $separator . $lf;
                }
                // end   for ($ic ...
                //echo "<pre>reactant query for query reactant no. $iq:\n$sdf\n</pre>";
                // now do the match
                if ($use_cmmmsrv == "y") {
                    $matchresult = filterthroughcmmm("{$sdf}", "#### matchmol:{$optstr}");
                } else {
                    if ($ostype == 1) {
                        $matchresult = filterthroughcmd("{$sdf} ", "{$mmcmd}");
                    }
                    if ($ostype == 2) {
                        $sdf = str_replace("\r", "", $sdf);
                        // for Windows
                        $sdf = str_replace("\n", "\r\n", $sdf);
                        // for Windows
                        $matchresult = filterthroughcmd2("{$sdf} ", "{$mmcmd}");
                    }
                }
                //echo "<pre>match result for for query reactant no. $iq:\n$matchresult\n</pre>";
                $br = explode("\n", $matchresult);
                $nr = count($br);
                for ($ir = 0; $ir < $nr; $ir++) {
                    if (strpos($br[$ir], ":T") !== FALSE) {
                        $rmm[$iq][$ir] = $br[$ir];
                    }
                }
            }
            // end   for ($iq ....
            // we have to clean up the matrix to remove multiple hits of one query mol
            if ($nqrmol > 1) {
                $rmm = cleanup_matrix($rmm);
            }
        }
        // end    if ($nqrmol > 0)
        //============ now match the products, if there are any
        if ($nqpmol > 0 && $ncpmol > 0) {
            // assemble the SDF files to be passed to matchmol
            for ($iq = 0; $iq < $nqpmol; $iq++) {
                $qmol = rtrim($qpmol[$iq]);
                $sdf = $qmol . $lf . $separator . $lf;
                for ($ic = 0; $ic < $ncpmol; $ic++) {
                    $cmol = rtrim($cpmol[$ic]);
                    $sdf .= $cmol . $lf . $separator . $lf;
                }
                // end   for ($ic ...
                //echo "<pre>product query for query product no. $iq:\n$sdf\n</pre>";
                // now do the match
                //$sdf = str_replace("\r","",$sdf);
                if ($use_cmmmsrv == "y") {
                    $matchresult = filterthroughcmmm("{$sdf}", "#### matchmol:{$optstr}");
                } else {
                    if ($ostype == 1) {
                        $matchresult = filterthroughcmd("{$sdf} ", "{$mmcmd}");
                    }
                    if ($ostype == 2) {
                        $sdf = str_replace("\r", "", $sdf);
                        // for Windows
                        $sdf = str_replace("\n", "\r\n", $sdf);
                        // for Windows
                        $matchresult = filterthroughcmd2("{$sdf} ", "{$mmcmd}");
                    }
                }
                //echo "<pre>match result for for query product no. $iq:\n$matchresult\n</pre>";
                $br = explode("\n", $matchresult);
                $nr = count($br);
                for ($ir = 0; $ir < $nr; $ir++) {
                    if (strpos($br[$ir], ":T") !== FALSE) {
                        $pmm[$iq][$ir] = $br[$ir];
                    }
                }
            }
            // end   for ($iq ....
            // we have to clean up the matrix to remove multiple hits of one query mol
            if ($nqpmol > 1) {
                $pmm = cleanup_matrix($pmm);
            }
        }
        // end    if ($nqpmol > 0)
        //echo "<pre>\n";
        if ($debug == 4 || $debug == 6) {
            echo "<pre>now the reactant match matrix looks like this:\n";
            print_matrix($rmm);
            echo "and the product match matrix looks like this:\n";
            print_matrix($pmm);
            echo "</pre>";
        }
        // and finally we check if every query structure matches a candidate structure
        // first check: reactants
        $foundallreactants = TRUE;
        for ($iq = 0; $iq < $nqrmol; $iq++) {
            $foundthisreactant = FALSE;
            for ($ic = 0; $ic < $ncrmol; $ic++) {
                if (strpos($rmm[$iq][$ic], ":T") !== FALSE) {
                    $foundthisreactant = TRUE;
                }
            }
            if ($foundthisreactant == FALSE) {
                $foundallreactants = FALSE;
            }
        }
        // second check: products
        $foundallproducts = TRUE;
        for ($iq = 0; $iq < $nqpmol; $iq++) {
            $foundthisproduct = FALSE;
            for ($ic = 0; $ic < $ncpmol; $ic++) {
                if (strpos($pmm[$iq][$ic], ":T") !== FALSE) {
                    $foundthisproduct = TRUE;
                }
            }
            if ($foundthisproduct == FALSE) {
                $foundallproducts = FALSE;
            }
        }
        // now let's draw the conclusion:
        if ($foundallreactants == FALSE || $foundallproducts == FALSE) {
            $result = FALSE;
        } else {
            // now we should consider atom mappings, if present
            if ($n_qmaps > 0 && $n_cmaps > 0) {
                $allmapsconfirmed = TRUE;
                for ($iqm = 0; $iqm < $n_qmaps; $iqm++) {
                    $thismapconfirmed = FALSE;
                    if ($debug > 2) {
                        debug_output("now checking query map no. {$iqm}: {$qmap_list[$iqm]}\n");
                    }
                    // split map into reactant and product part
                    $qmarr = explode("=", $qmap_list[$iqm]);
                    $qrpart = $qmarr[0];
                    $qppart = $qmarr[1];
                    if ($debug > 2) {
                        debug_output("query reactant: {$qrpart}     query product: {$qppart}\n");
                    }
                    // extract mol id and atom id
                    $qrarr = explode(":", $qrpart);
                    $qrmid = $qrarr[0];
                    $qrmidn = str_replace("r", "", $qrmid);
                    $qrmidn = intval($qrmidn) - 1;
                    $qraid = $qrarr[1];
                    $qparr = explode(":", $qppart);
                    $qpmid = $qparr[0];
                    $qpmidn = str_replace("p", "", $qpmid);
                    $qpmidn = intval($qpmidn) - 1;
                    $qpaid = $qparr[1];
                    // now look up in the reactant match matrix which candidate reactant(s)
                    // match with this query reactant
                    if ($debug > 2) {
                        debug_output("   checking reactant match matrix for query reactant {$qrmid} ({$qrmidn})\n");
                    }
                    for ($irmm = 0; $irmm < $ncrmol; $irmm++) {
                        if ($rmm[$qrmidn][$irmm] !== "0") {
                            // assemble the id string
                            $crmidn = $irmm;
                            $crmid = $crmidn + 1;
                            $crmid = "r" . $crmid . ":";
                            if ($debug > 2) {
                                debug_output("   ---- there is a matching candidate reactant: {$crmid} ({$crmidn})\n");
                            }
                            // now check if there is a suitable counterpart on the product side
                            if ($debug > 2) {
                                debug_output("   checking product match matrix for query product {$qpmid} ({$qpmidn})\n");
                            }
                            for ($ipmm = 0; $ipmm < $ncpmol; $ipmm++) {
                                if ($pmm[$qpmidn][$ipmm] !== "0") {
                                    // assemble the id string
                                    $cpmidn = $ipmm;
                                    $cpmid = $cpmidn + 1;
                                    $cpmid = "p" . $cpmid . ":";
                                    if ($debug > 2) {
                                        debug_output("   ---- there is a matching candidate product: {$cpmid} ({$cpmidn})\n");
                                    }
                                    // now we can check the atom mappings....
                                    // first, go through the list of candidate maps and look for a map
                                    for ($icm = 0; $icm < $n_cmaps; $icm++) {
                                        $cmarr = explode("=", $cmap_list[$icm]);
                                        $crpart = $cmarr[0];
                                        $cppart = $cmarr[1];
                                        if ($debug > 2) {
                                            debug_output("  checking query map {$iqm} against candidate map {$icm}\n");
                                        }
                                        if ($debug > 2) {
                                            debug_output("    ==== candidate reactant: {$crpart}     candidate product: {$cppart}\n");
                                        }
                                        // extract mol id and atom id
                                        $crarr = explode(":", $crpart);
                                        $crmid2 = $crarr[0];
                                        $crmid2n = str_replace("r", "", $crmid2);
                                        $crmid2n = intval($crmid2n) - 1;
                                        $craid2 = trim($crarr[1]);
                                        $cparr = explode(":", $cppart);
                                        $cpmid2 = $cparr[0];
                                        $cpmid2n = str_replace("p", "", $cpmid2);
                                        $cpmid2n = intval($cpmid2n) - 1;
                                        $cpaid2 = trim($cparr[1]);
                                        // check for presence of both mol identifiers
                                        if (strpos($crpart, $crmid) !== FALSE && strpos($cppart, $cpmid) !== FALSE) {
                                            if ($debug > 2) {
                                                debug_output("    **** found a map: {$cmap_list[$icm]}\n");
                                            }
                                            // now do some atom-number translation...
                                            // first, get the atom match matrix for this pair of reactants
                                            $rmmitem = $rmm[$qrmidn][$irmm];
                                            $rmmitemarr = explode(":T ", $rmmitem);
                                            $rmmitem = $rmmitemarr[1];
                                            // next, get the atom match matrix for this pair of products
                                            $pmmitem = $pmm[$qpmidn][$ipmm];
                                            $pmmitemarr = explode(":T ", $pmmitem);
                                            $pmmitem = $pmmitemarr[1];
                                            if ($debug > 2) {
                                                debug_output("    reactant atom map: {$rmmitem}\n");
                                                debug_output("    product atom map:  {$pmmitem}\n");
                                            }
                                            // now extract all possible orientations from the atom maps
                                            $ror = explode(".", $rmmitem);
                                            $n_ror = count($ror);
                                            $por = explode(".", $pmmitem);
                                            $n_por = count($por);
                                            for ($i_ror = 0; $i_ror < $n_ror; $i_ror++) {
                                                if ($debug > 4) {
                                                    debug_output("    trying reactant orientation no. {$i_ror}: {$ror[$i_ror]}\n");
                                                }
                                                $ratom = $ror[$i_ror];
                                                $ratomarr = explode(";", $ratom);
                                                foreach ($ratomarr as $ra) {
                                                    //echo "    reactant atom pair: $ra\n";
                                                    $ra2arr = explode("=", $ra);
                                                    $rqa = $ra2arr[0];
                                                    $rcalist = "";
                                                    $rcalist = $ra2arr[1];
                                                    if ($debug > 4) {
                                                        debug_output("    query reactant atom {$rqa} corresponds to candidate reactant atom(s): {$rcalist}\n");
                                                    }
                                                    if ($qraid == $rqa) {
                                                        if ($debug > 4) {
                                                            debug_output("    .... this is interesting! (rqa = {$rqa})\n");
                                                        }
                                                        // get all sub-orientations
                                                        $rca2arr = explode(",", $rcalist);
                                                        foreach ($rca2arr as $rca) {
                                                            $rca = trim($rca);
                                                            // this is important!
                                                            if ($debug > 4) {
                                                                debug_output("    labelled query reactant atom {$rqa} corresponds to candidate reactant atom: {$rca}\n");
                                                                debug_output("      craid2 = {$craid2} rca = {$rca} rqa = {$rqa}\n");
                                                            }
                                                            if ($rca == $craid2) {
                                                                if ($debug > 4) {
                                                                    debug_output("    found a label counterpart for {$qraid}: {$craid2}!!\n");
                                                                    debug_output("    who is the counterpart of query product atom {$qpaid}? is it {$cpaid2}?\n");
                                                                }
                                                                // now look up the product end...
                                                                // check all possible reactant orientations....
                                                                for ($i_por = 0; $i_por < $n_por; $i_por++) {
                                                                    if ($debug > 4) {
                                                                        debug_output("    trying product orientation no. {$i_por}: {$por[$i_por]}\n");
                                                                    }
                                                                    $patom = $por[$i_por];
                                                                    $patomarr = explode(";", $patom);
                                                                    foreach ($patomarr as $pa) {
                                                                        //echo "    product atom pair: $pa\n";
                                                                        $pa2arr = explode("=", $pa);
                                                                        $pqa = trim($pa2arr[0]);
                                                                        $pcalist = "";
                                                                        $pcalist = $pa2arr[1];
                                                                        if ($debug > 6) {
                                                                            debug_output("        query product atom {$pqa} corresponds to candidate product atom(s): {$pcalist}\n");
                                                                        }
                                                                        if ($qpaid == $pqa) {
                                                                            if ($debug > 6) {
                                                                                debug_output("        NOW IT BECOMES INTERESTING!\n");
                                                                            }
                                                                            // again, get all sub-orientations
                                                                            $pca2arr = explode(",", $pcalist);
                                                                            foreach ($pca2arr as $pca) {
                                                                                $pca = trim($pca);
                                                                                // this is important!
                                                                                if ($debug > 6) {
                                                                                    debug_output("            query product atom {$qpaid} corresponds to candidate product atom: {$pca}\n");
                                                                                }
                                                                                if ($cpaid2 == $pca) {
                                                                                    $thismapconfirmed = TRUE;
                                                                                    if ($debug > 2) {
                                                                                        debug_output("BINGO!!!! confirmed query map no. {$iqm}\n");
                                                                                    }
                                                                                    break 7;
                                                                                    // immediately stop looping (7 depth levels!)
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($thismapconfirmed == FALSE) {
                        $allmapsconfirmed = FALSE;
                        if ($debug > 2) {
                            debug_output("==== could not confirm query map no. {$iqm}\n");
                        }
                    }
                }
                if ($allmapsconfirmed == FALSE) {
                    $result = FALSE;
                }
            }
            // end of "if we have both maps..."
        }
    }
    // end if ($result == TRUE) from initial check
    return $result;
}