#!/usr/local/bin/perl -w
my
$config
= {
title
=>
'UniProt Slice FAIR Accessor - Aspergillus RNA Processing proteins'
,
serviceTextualDescription
=>
'Takes a SAPRQL query of the UniProt database specific to proteins and their GO annotations related to RNA Procssing proteins in Aspergillus and makes it a FAIR Accessor source'
,
textualAccessibilityInfo
=>
"The information from this server requries no authentication; HTTP GET is sufficient"
,
mechanizedAccessibilityInfo
=>
""
,
textualLicenseInfo
=>
"CC-BY-ND 4.0"
,
ETAG_Base
=>
"TopLevelMetadata_Accessor_For_UniProtAnidulansRNAProcessing"
,
localNamespaces
=> {
},
basePATH
=>
'/Accessors/UniProtAccessor'
,
};
my
$SPARQL
= '
SELECT distinct ?id
WHERE
{
?protein a up:Protein .
?protein up:organism ?organism .
?organism rdfs:subClassOf taxon:162425 .
?protein up:classifiedWith ?go .
}
';
my
$service
= UniProtAccessor->new(
%$config
);
$service
->handle_requests;
sub
Container {
my
(
$self
,
%ARGS
) =
@_
;
my
$Container
= FAIR::Accessor::Container->new(
NS
=>
$self
->Configuration->Namespaces);
$self
->fillContainerMetadata(
$Container
);
my
$BASE_URL
=
"http://"
.
$ENV
{
'SERVER_NAME'
} .
$ENV
{
'REQUEST_URI'
};
my
$query
= RDF::Query::Client->new(
$SPARQL
);
my
@records
;
while
(
my
$row
=
$iterator
->
next
) {
my
$ID
=
$row
->{id}->value;
push
@records
,
"$BASE_URL/$ID"
;
}
$Container
->addRecords(\
@records
);
return
$Container
;
}
sub
MetaRecord {
my
(
$self
,
%ARGS
) =
@_
;
my
$ID
=
$ARGS
{
'ID'
};
my
$MetaRecord
= FAIR::Accessor::MetaRecord->new(
ID
=>
$ID
,
NS
=>
$self
->Configuration->Namespaces);
$self
->fillMetaRecordMetadata(
$MetaRecord
);
$MetaRecord
->addDistribution(
availableformats
=> [
'text/html'
],
$MetaRecord
->addDistribution(
availableformats
=> [
'application/rdf+xml'
],
my
$desc
=
$self
->getDesc(
$ID
);
$MetaRecord
->addMetadata({
'dcat:description'
=>
$desc
});
$MetaRecord
->addDistribution(
availableformats
=> [
"application/x-turtle"
,
"application/rdf+xml"
,
"text/html"
],
downloadURL
=>
$TPF
,
);
$MetaRecord
->addDistribution(
availableformats
=> [
"application/x-turtle"
,
"application/rdf+xml"
,
"text/html"
],
downloadURL
=>
$TPF
,
);
return
$MetaRecord
;
}
sub
fillContainerMetadata {
my
(
$self
,
$Container
) =
@_
;
$Container
->addMetadata({
'dc:title'
=>
"UniProt Slice FAIR Accessor - Aspergillus RNA Processing proteins"
,
'dcat:description'
=>
"Takes a SPARQL query of the UniProt database specific to proteins and their GO annotations related to RNA Procssing proteins in Aspergillus and makes it a FAIR Accessor source. The precise query is:\n\n$SPARQL "
,
'dcat:keyword'
=> [
"Aspergillus"
,
"Aspergillus nidulans"
,
"RNA Processing"
,
"Proteins"
],
'pfund:hasPrincipalInvestigator'
=> [
"Dr. Mark Wilkinson"
],
'pav:version'
=>
'UniProt release 2016_09'
,
'rdf:type'
=> [
'prov:Collection'
,
'dctypes:Dataset'
],
});
}
sub
fillMetaRecordMetadata {
my
(
$self
,
$MetaRecord
) =
@_
;
my
$ID
=
$MetaRecord
->ID;
$MetaRecord
->addMetadata({
'dc:title'
=>
"UniProt Protein $ID"
,
'dcat:keyword'
=> [
"Aspergillus"
,
"Aspergillus nidulans"
,
"RNA Processing"
,
"Proteins"
,
"Annotation"
,
"Functinal Annotation"
,
"Gene Ontology"
,
"GO"
],
'pav:version'
=>
'UniProt release 2016_09'
,
'dc:creator'
=>
'UniProt Consortium'
,
'dc:bibliographicCitation'
=>
"The UniProt Consortium (2015). UniProt: a hub for protein information. Nucleic Acids Res. 43: D204-D212"
,
});
}
sub
urlencode {
my
$s
=
shift
;
$s
=~ s/ /+/g;
$s
=~ s/([^A-Za-z0-9\+-])/
sprintf
(
"%%%02X"
,
ord
($1))/seg;
return
$s
;
}
sub
getDesc {
my
(
$self
,
$ID
) =
@_
;
my
$store
= RDF::Trine::Store::Memory->new();
my
$model
= RDF::Trine::Model->new(
$store
);
select
?desc where
{
?x a core:Structured_Name .
?x core:fullName ?desc .
}
' );
my
$desc
;
my
$iterator
=
$query
->execute(
$model
);
while
(
my
$row
=
$iterator
->
next
) {
$desc
.= (
$row
->{
'desc'
}->value).
"\n"
;
}
return
$desc
}