-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconvertExprs_agilent.pl
62 lines (55 loc) · 1.55 KB
/
convertExprs_agilent.pl
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
#!/usr/bin/perl
use strict;
use FileHandle;
my $file_dir = '/home/zhenyisong/data/wanglilab/GSE76720';
chdir($file_dir);
my $annotion_file_name = 'GPL13497-9755.txt';
my $matrix_file_name = 'GSE76720_series_matrix.txt';
my $input_fh = FileHandle->new($matrix_file_name);
my $annotation = readAnnotationTable($annotion_file_name);
my $result_dir = '/home/zhenyisong/data/wanglilab/non_standard_results';
my $output_file = $matrix_file_name;
chdir($result_dir);
my $output_fh = FileHandle->new(">$output_file");
while (my $line = $input_fh->getline) {
chomp $line;
if ($line =~ /^!/) {
next;
}
$line =~ s/\"//g;
if ($line =~ /^ID/) {
$output_fh->print($line);
$output_fh->print("\n");
}
my @buffer = split(/\t/,$line);
if (exists $annotation->{$buffer[0]}) {
$buffer[0] = $annotation->{$buffer[0]};
}
else {
next;
}
my $last_element = pop(@buffer);
foreach my $item (@buffer) {
$output_fh->print($item);
$output_fh->print("\t");
}
$output_fh->print($last_element);
$output_fh->print("\n");
}
$output_fh->close;
$input_fh->close;
sub readAnnotationTable {
my $file = shift;
my $fh = FileHandle->new($file);
my $result = undef;
while(my $line = $fh->getline) {
if ($line =~ /^A_/) {
my @buffer = split(/\t/,$line);
if ($buffer[6] =~ /\w+/) {
$result->{$buffer[0]} = $buffer[6];
}
}
}
$fh->close;
return $result;
}