Hoy os publico una viñeta que me ha hecho gracia y se adapta muy bien a la bioinformática... desgraciadamente se cumple totalmente, sobretodo lo del conserje...
El original aquí: http://sinergiasincontrol.blogspot.com/2008/10/33-suposiciones.html
Ideas y código para problemas de genómica de plantas, biología computacional y estructural
use SOAP::Lite;
my $pubmed_id = '24234003';
my $WSDL = 'http://www.ncbi.nlm.nih.gov/soap/v2.0/efetch_pubmed.wsdl';
my $soap = SOAP::Lite->service($WSDL)
->on_fault( sub { my($self, $res) = @_;
die
"faultcode:", ref $res ? $res->faultcode : $self->transport->status, "\n" ,
"faultstring:", ref $res ? $res->faultstring : $self->transport->status, "\n";
});
my $response = $soap->run_eFetch( SOAP::Data->name(id => $pubmed_id),
SOAP::Data->name(db => "pubmed")
);
my %results;
if (ref($response) eq "HASH") {
$results{'title'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'ArticleTitle'};
$results{'journal'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'Journal'}{'Title'};
$results{'pubmed'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'PMID'};
$results{'volume'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'Journal'}{'JournalIssue'}{'Volume'};
$results{'issue'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'Journal'}{'JournalIssue'}{'Issue'};
$results{'year'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'Journal'}{'JournalIssue'}{'PubDate'}{'Year'};
$results{'pages'} = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'Pagination'}{'MedlinePgn'};
$results{'url'} = 'http://www.ncbi.nlm.nih.gov/pubmed/'.$results{'pubmed'};
if (ref($response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'AuthorList'}{'Author'}) eq "ARRAY") {
my @authors;
foreach my $author (@{$response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'AuthorList'}{'Author'}}){
my $initials = join('.',split('',$author->{'Initials'}));
push(@authors, $author->{'LastName'}." ".$initials);
}
$results{'authors'} = join(", ",@authors);
} elsif (ref($response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'AuthorList'}{'Author'}) eq "HASH") {
my $author = $response->{'PubmedArticle'}{'MedlineCitation'}{'Article'}{'AuthorList'}{'Author'};
my $initials = join('.',split('',$author->{'Initials'}));
$results{'authors'} = $author->{'LastName'}." ".$initials;
}
foreach my $key (keys %{$results}){
if (!defined($results{$key})) {
$results{$key} = '';
}
}
}
print %results;
use LWP::Simple;
my $pubmed_id = '24234003';
my $eutils_url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/';
my $eutil = 'efetch';
my $db = 'pubmed';
my $type = 'docsum';
my $mode = 'text';
my $url = sprintf('%s%s.fcgi?db=%s&id=%s&rettype=%s&retmode=%s', $eutils_url, $eutil, $db, $pubmed_id, $type, $mode);
my $data = get($url);
my %results;
if (defined($data)){
$data =~ s/\012\015?|\015\012?/ /g;
if ($data =~ /\d+\:\s*(.+?)\.(.+?)\.(.+?)\.(.+?)\s.+?\;(\d+)\((\d+)\)\:([\d\-]+)./){
@{$results{'authors'}} = split(/,\s?/,$1);
$results{'title'} = $2;
$results{'journal'} = $3;
$results{'year'} = $4;
$results{'volume'} = $5;
$results{'issue'} = $6;
$results{'pages'} = $7;
$results{'pubmed'} = $pubmed_id;
$results{'url'} = 'http://www.ncbi.nlm.nih.gov/pubmed/'.$pubmed_id;
} elsif ($data =~ /\d+\:\s*(.+?)\.(.+?)\.(.+?)\.(.+?)\s/){
@{$results{'authors'}} = split(/,\s?/,$1);
$results{'title'} = $2;
$results{'journal'} = $3;
$results{'year'} = $4;
$results{'pubmed'} = $pubmed_id;
$results{'url'} = 'http://www.ncbi.nlm.nih.gov/pubmed/'.$pubmed_id;
}
}
while (my ($key, $value) = each %results) {
if (ref($value) ne ARRAY){
printf("%s: %s\n", $key, $value);
} else {
printf("%s: %s\n", $key, join(', ',@$value));
}
}
use Bio::DB::EUtilities;
my $pubmed_id = '24234003';
my $eutil = 'efetch';
my $db = 'pubmed';
my $type = 'docsum';
my $mode = 'text';
my $email = 'mymail@foo.bar';
my $factory = Bio::DB::EUtilities->new( -eutil => $eutil,
-db => $db,
-id => $pubmed_id,
-email => $email,
-rettype => $type,
-retmode => $mode
);
my $data = $factory->get_Response->content;
my %results;
if (defined($data)){
$data =~ s/\012\015?|\015\012?/ /g;
if ($data =~ /\d+\:\s*(.+?)\.(.+?)\.(.+?)\.(.+?)\s.+?\;(\d+)\((\d+)\)\:([\d\-]+)./){
@{$results{'authors'}} = split(/,\s?/,$1);
$results{'title'} = $2;
$results{'journal'} = $3;
$results{'year'} = $4;
$results{'volume'} = $5;
$results{'issue'} = $6;
$results{'pages'} = $7;
$results{'pubmed'} = $pubmed_id;
$results{'url'} = 'http://www.ncbi.nlm.nih.gov/pubmed/'.$pubmed_id;
} elsif ($data =~ /\d+\:\s*(.+?)\.(.+?)\.(.+?)\.(.+?)\s/){
@{$results{'authors'}} = split(/,\s?/,$1);
$results{'title'} = $2;
$results{'journal'} = $3;
$results{'year'} = $4;
$results{'pubmed'} = $pubmed_id;
$results{'url'} = 'http://www.ncbi.nlm.nih.gov/pubmed/'.$pubmed_id;
}
}
while (my ($key, $value) = each %results) {
if (ref($value) ne ARRAY){
printf("%s: %s\n", $key, $value);
} else {
printf("%s: %s\n", $key, join(', ',@$value));
}
}
from Bio import Entrez
pubmed_id = '24234003';
handle = Entrez.efetch(db='pubmed', id=pubmed_id, rettype='docsum', retmode="xml", email='mymail@foo.bar')
results = Entrez.read(handle)
for key, value in results[0].iteritems():
print "%s: %s" % (key,value)