line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Microarray::GEO::SOFT::GPL;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# parse the GPL part in GSE file
|
4
|
|
|
|
|
|
|
# or the GPL file itself
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1707
|
use List::Vectorize qw(!table);
|
|
1
|
|
|
|
|
25239
|
|
|
1
|
|
|
|
|
666
|
|
7
|
1
|
|
|
1
|
|
10
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
8
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base "Microarray::GEO::SOFT";
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
773
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1;
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new {
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $invocant = shift;
|
17
|
|
|
|
|
|
|
my $class = ref($invocant) || $invocant;
|
18
|
|
|
|
|
|
|
my $self = { "file" => "",
|
19
|
|
|
|
|
|
|
"verbose" => 1,
|
20
|
|
|
|
|
|
|
@_ };
|
21
|
|
|
|
|
|
|
bless($self, $class);
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return $self;
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub parse {
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $self = shift;
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $fh;
|
32
|
|
|
|
|
|
|
if(! List::Vectorize::is_glob_ref($self->{file})) {
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
open F, $self->{file} or croak "cannot open $self->{file}.\n";
|
35
|
|
|
|
|
|
|
$fh = \*F;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
else {
|
38
|
|
|
|
|
|
|
$fh = $self->{file};
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$self->_parse_platform($fh);
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return 1;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _parse_platform {
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $self = shift;
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $fh = shift;
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Microarray::GEO::SOFT::_set_fh($self->{verbose});
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $accession;
|
55
|
|
|
|
|
|
|
my $title;
|
56
|
|
|
|
|
|
|
my $table_colnames = [];
|
57
|
|
|
|
|
|
|
my $table_rownames = [];
|
58
|
|
|
|
|
|
|
my $table_matrix = [];
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
while(my $line = <$fh>) {
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
chomp $line;
|
63
|
|
|
|
|
|
|
if($line =~/^!Platform_geo_accession = (GPL\d+)$/
|
64
|
|
|
|
|
|
|
or $line =~/^!Annotation_platform = (GPL\d+)/) {
|
65
|
|
|
|
|
|
|
$accession = $1;
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
if($line =~/^!Platform_title = (.*?)$/
|
69
|
|
|
|
|
|
|
or $line =~/^!Annotation_platform_title = (.*?)$/) {
|
70
|
|
|
|
|
|
|
$title = $1;
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if($line =~/^!platform_table_begin$/) {
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$line = <$fh>;
|
76
|
|
|
|
|
|
|
chomp $line;
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
@$table_colnames = split "\t", $line, -1;
|
79
|
|
|
|
|
|
|
shift(@$table_colnames);
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
while($line = <$fh>) {
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
if($line =~/^!platform_table_end$/) {
|
84
|
|
|
|
|
|
|
last;
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
chomp $line;
|
88
|
|
|
|
|
|
|
my @tmp = split "\t", $line, -1;
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $uid = shift(@tmp);
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
push(@$table_rownames, $uid);
|
93
|
|
|
|
|
|
|
push(@$table_matrix, [@tmp]);
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
if($line =~/^!platform_table_end$/) {
|
100
|
|
|
|
|
|
|
last;
|
101
|
|
|
|
|
|
|
}
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $n_row = len($table_rownames);
|
106
|
|
|
|
|
|
|
my $n_col = len($table_colnames);
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $platform = $accession;
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
print "Platform info:\n";
|
111
|
|
|
|
|
|
|
print " Accession: $accession\n";
|
112
|
|
|
|
|
|
|
print " Platform: $platform\n";
|
113
|
|
|
|
|
|
|
print " Title: $title\n";
|
114
|
|
|
|
|
|
|
print " Rows: $n_row\n";
|
115
|
|
|
|
|
|
|
print " Columns: $n_col\n";
|
116
|
|
|
|
|
|
|
print "\n";
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$self->set_meta( accession => $accession,
|
119
|
|
|
|
|
|
|
title => $title,
|
120
|
|
|
|
|
|
|
platform => $platform );
|
121
|
|
|
|
|
|
|
$self->set_table( rownames => $table_rownames,
|
122
|
|
|
|
|
|
|
colnames => $table_colnames,
|
123
|
|
|
|
|
|
|
matrix => $table_matrix );
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Microarray::GEO::SOFT::_set_to_std_fh();
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return $self;
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# map new ID from the order of the first column
|
131
|
|
|
|
|
|
|
sub _mapping {
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $self = shift;
|
134
|
|
|
|
|
|
|
my $to_id = shift;
|
135
|
|
|
|
|
|
|
my $from_list = shift;
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $mapping;
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $to_index;
|
140
|
|
|
|
|
|
|
my $colnames = $self->colnames;
|
141
|
|
|
|
|
|
|
for(my $i = 0; $i < len($colnames); $i ++) {
|
142
|
|
|
|
|
|
|
if($colnames->[$i] eq $to_id) {
|
143
|
|
|
|
|
|
|
$to_index = $i;
|
144
|
|
|
|
|
|
|
last;
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
if(! defined($to_index)) {
|
149
|
|
|
|
|
|
|
croak "ERROR: Cannot find ID ($to_id) in ".$self->platform."\n";
|
150
|
|
|
|
|
|
|
}
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $mat = $self->matrix;
|
153
|
|
|
|
|
|
|
my $hash;
|
154
|
|
|
|
|
|
|
my $rownames = $self->rownames;
|
155
|
|
|
|
|
|
|
for(my $i = 0; $i < len($mat); $i ++) {
|
156
|
|
|
|
|
|
|
if($mat->[$i]->[$to_index] =~/^(.*?)\/\/\//) {
|
157
|
|
|
|
|
|
|
$hash->{$rownames->[$i]} = $1;
|
158
|
|
|
|
|
|
|
}
|
159
|
|
|
|
|
|
|
else {
|
160
|
|
|
|
|
|
|
$hash->{$rownames->[$i]} = $mat->[$i]->[$to_index];
|
161
|
|
|
|
|
|
|
}
|
162
|
|
|
|
|
|
|
}
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
for (@$from_list) {
|
165
|
|
|
|
|
|
|
push(@$mapping, $hash->{$_});
|
166
|
|
|
|
|
|
|
}
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
return $mapping;
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
}
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
__END__
|