Leser: 2
|< 1 2 >| | 12 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
...
<Entrezgene_unique-keys>
<Dbtag>
<Dbtag_db>HGNC</Dbtag_db>
<Dbtag_tag>
<Object-id>
<Object-id_id>5</Object-id_id>
</Object-id>
</Dbtag_tag>
</Dbtag>
<Dbtag>
<Dbtag_db>LocusID</Dbtag_db>
<Dbtag_tag>
<Object-id>
<Object-id_id>1</Object-id_id>
</Object-id>
</Dbtag_tag>
</Dbtag>
<Dbtag>
<Dbtag_db>MIM</Dbtag_db>
<Dbtag_tag>
<Object-id>
<Object-id_id>138670</Object-id_id>
</Object-id>
</Dbtag_tag>
</Dbtag>
</Entrezgene_unique-keys>
...
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
#!/usr/bin/perl -w
use warnings;
use strict;
use DBI;
use XML::Twig; #http://xmltwig.com/xmltwig/tutorial/yapc_twig_s4.html for good references!!!
header();
my $twig = new XML::Twig(
TwigHandlers => #Gene-track element will be called when each player element has been parsed
{
"Entrezgene_unique-keys" => \&dbxref
#"Dbtag_tag" => \&dbxref #funzt nicht, weil es mehere TagElemente diesen Typs gibt
#"Object-id_id" => \&dbxref #funzt nicht, weil es mehere TagElemente diesen Typs gibt
}
);
$twig->parsefile("Homo_sapiens.ags"); #built the twig
sub dbxref {
my ($twig, $dbxref) = @_;
#leider gehen diese Ansätze nicht, da ich nur das 'erste Kind' erfassen kann. Wie kann ich weitere Subelemente aufrufen?
my $id = first_child('Dbtag') #->second_child('Dbtag_db')->text;
my $db = first_child('Dbtag') #->second_child('Dbtag_tag')->third_child('Object-id')->fourth_child('Obejct-id_id')->text;
print "$id\t$db\n";
}
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
...
my $global_db;
my $twig = new XML::Twig(
TwigRoots => #twig will be created only for Entrezgene_unique-keys elements
{ "Entrezgene_unique-keys" => 1 },
TwigHandlers => #Gene-track element will be called when each player element has been parsed
{
"Dbtag_db" => \&dbxref, #here $twig->purge forbitten, because the data of the twig are needed for &generef
"Object-id_id" => \&dbid
}
);
...
sub dbxref {
my ($twig, $dbxref) = @_;
my $db = '??';
if ($dbxref->text) {
$db = $dbxref->text;
}
$global_db = $db;
$twig -> purge;
$dbxref -> delete;
}
sub dbid {
my ($twig, $dbid) = @_;
my $id = '??';
if ($dbid->text) {
$id = $dbid->text;
}
print "$global_db - $id\n";
$twig -> purge;
$dbid -> delete;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Kopfdaten
Kopfdaten
Kopfdaten
<Klammer>
<Sub>
...
</Sub>
<Sub>
...
</Sub>
<Sub>
...
</Sub>
<Sub>
...
</Sub>
...
</Klammer>
|< 1 2 >| | 12 Einträge, 2 Seiten |