<?php

$page_dir = str_replace('\\', '/', dirname(__FILE__)) . '/';
$serv_dir = $page_dir . "../../service/";
require_once $serv_dir . 'cegRecordServ.php';
require_once $serv_dir . 'keggServ.php';
require_once $serv_dir . 'util.php';
$flag = 0;
if (isset($_GET['access_num'])) {
    $flag = 1;
    $accessNum = trim($_GET['access_num']);
    $cegBase = getCegBaseByAccessNum($accessNum);
    $gidArr = getGidByAccessNum($accessNum);
    $itemArr = array();
    foreach ($gidArr as $gid) {
        $annotation = getAnnotationByGid($gid);
        $item['gid'] = $gid;
        $item['gene_name'] = $annotation['Gene_Name'];
        $item['description'] = $annotation['fundescrp'];
        $item['sequence'] = getPlainNaSeq($gid);
        $item['rfc_arr'] = getCompatibleRFC($item['sequence']);
        $item['biobrick_arr'] = getBiobrickByGid($gid);
        array_push($itemArr, $item);
    }
}
if (!$flag) {
    die;
}
?>

<!DOCTYPE html>
/**
 * get all nucleic acid sequence by Access_num
 * @param type $accessNum
 * @return array
 */
function getNaSeqByAccessNum($accessNum)
{
    $result = array();
    $gidArr = getGidByAccessNum($accessNum);
    foreach ($gidArr as $gid) {
        $naSeq = getNaSeq($gid);
        array_push($result, $naSeq);
    }
    return $result;
}