<?php

  require '../conf/config.php';

  //////////////////////////////////  Connecting with DB
  $conn = mysql_connect($host, $user, $pswd);
  $db = mysql_select_db($db);

  ////////////////////////////////////////////////////////// Chromosome
  $chr = array();
  $size = array();
  $centomeres = array();
  $query = "SELECT id,size,centromere_s+(centromere_e-centromere_s)/2 FROM sys_chromosome order by seq";
  $result = mysql_query($query);
  while ($row = mysql_fetch_row($result)) {
    $chr[]=$row[0];
    $size[]=$row[1];
    $centromeres[]=(int)$row[2];
  }

  $str="[";
  for ($i=0; $i<count($chr); $i++) {
    $str=$str."{\"id\":\"".$chr[$i]."\",\"size\":\"".$size[$i]."\",\"centromere\":\"".$centromeres[$i]."\"}"; 
    if($i<count($chr)-1) $str=$str.",";
  }
  $str=$str."]";

  echo $str;

?>

