Leser: 1
|< 1 2 >| | 19 Einträge, 2 Seiten |
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
#!/usr/local/bin/perl -w
#use strict;
#use warnings;
use DBI;
use Net::MySQL;
use HTTP::Request::Common;
use LWP::UserAgent;
use CGI qw(header -no_debug);
use XML::Twig;
#==============================database connection================================================
print "trying to connect to database \n";
my $database = '';
my $host = '';
my $user = '';
my $password = '';
my $mysql = Net::MySQL->new(
hostname => $host,
database => $database,
user => $user,
password => $password,
);
print "Connection established \n";
#=============================end database connection==================================================
$mysql->query(qq{SELECT accession_code FROM protein});
my $record_set = $mysql->create_record_iterator;
while (my $record = $record_set->each) {
print "Accession ID: $record->[0] \n";
#For retrieving data from a url post in perl, we will use the LWP module "get" function
use LWP::Simple; #supports the "get" function
$baseurl="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/";
$eutil="esearch.fcgi?";
$parameters="db=protein&term=$record->[0]&retmode=xml"; #db=protein&id=gi_id db=taxonomy&id=tax_id
$url=$baseurl.$eutil.$parameters; &nb
sp; &nb
sp;#term=$record->[0]
$raw=get($url);
open(FILE, ">$record->[0]"); &n
bsp; #$record->[0]
print FILE $raw;
close FILE;
$xml_file = $record->[0]; &n
bsp; #$record->[0]
my $twig= XML::Twig->new(
TwigHandlers => {
IdList => \&id_Tag
}
);
#actually parse the file
$twig->parsefile($xml_file) or die "cannot parse [$xml_file]: $!";
###########################################
sub id_Tag {
###########################################
my($t, $idTag)= @_;
unless($idTag->first_child('Id')->text) {
print "ID-tag leer\n";
}
my $id = $idTag->first_child('Id')->text;
print "GI_ID: ",$id,"\n";
# Release memory of processed tree up to here
$t->purge();
}
unlink($record->[0]);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Can't call method "text" on an undefined value at /home/Hubert/installed/eclipse/workspace/Database_Search/species.pl line 71.
trying to connect to database
Connection established
Accession ID: 140U_DROME
GI_ID: 29427659
Accession ID: 145L_
GI_ID: 15078858
Accession ID: 14KD_RHOSH
GI_ID: 231344
Accession ID: 194K_TRVSY
GI_ID: 112711
Accession ID: 1A02_PANTR
GI_ID: 122149
Accession ID: 1A0I_
GI_ID: 3114525
Accession ID: 1A0L_A
1
2
3
4
5
unless(defined $idTag->first_child('Id')) {
print "ID-tag leer\n";
} else {
print $idTag->first_child('Id')->text();
}
|< 1 2 >| | 19 Einträge, 2 Seiten |