-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqtl_alleles.php
executable file
·95 lines (73 loc) · 2.14 KB
/
qtl_alleles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
header("Content-type:text/plain");
include("includes/bootstrap.inc");
connect();
echo "line_name";
$select = "line_record_name";
$count = 1;
$query = mysql_query("SELECT marker_name FROM markers");
while ($marker = mysql_fetch_row($query)) {
//echo " $marker[0]";
$select .= ", v$count.value";
$count++;
}
$in = substr($in, 0, -1);
echo $in;
/*$data = array();
$result = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM line_records"));
$init_size = $size = $result[0];
$offset = 0;
echo "line_name ";
while ($size > 0){
$sql = "SELECT marker_name, marker_uid FROM markers";// WHERE marker_uid < 1000 LIMIT 30";
$res = mysql_query($sql);
if ($init_size == $size){
while($marker = mysql_fetch_assoc($res)){
array_push($data, intval($marker["marker_uid"]));
echo $marker["marker_name"] . " ";
}
echo "\n";
}
$sql = "SELECT line_record_name, line_record_uid FROM line_records WHERE 1 LIMIT $begin, 1";
$res = mysql_query($sql);
while($line = mysql_fetch_assoc($res)){
echo str_replace(' ', '_', $line["line_record_name"]) . " ";
foreach ($data as $marker_id){
echo getValue(intval($line["line_record_uid"]), $marker_id) . " ";
}
}
$size -= 1;
$offset += 1;
echo "\n";
}
function getValue($line_id, $marker_id){
$sql = <<< SQL
SELECT
alleles.value
FROM
alleles,
genotyping_data,
tht_base,
markers,
line_records
WHERE
line_records.line_record_uid = '$line_id'
AND markers.marker_uid = '$marker_id'
AND tht_base.line_record_uid = line_records.line_record_uid
AND genotyping_data.marker_uid = markers.marker_uid
AND tht_base.tht_base_uid = genotyping_data.tht_base_uid
AND genotyping_data.genotyping_data_uid = alleles.genotyping_data_uid
SQL;
$res = mysql_query($sql);
$num_rows = mysql_num_rows($res);
if ($num_rows > 0){
$row = mysql_fetch_assoc($res);
return convert($row["value"]);
}
return "NA";
}
function convert($value){
if ($value == 'A') return '-1';
else if ($value == 'B') return '1';
}*/
?>