Skip to content

Instantly share code, notes, and snippets.

@andrawaag
andrawaag / getSparqlAsCSV.pl
Created July 11, 2013 10:59
This perl scripts returns the results of a sparql query to return Pathway elements that don't contain no DataSource or Identifier
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
my $sparql = "SELECT DISTINCT ?wpIdentifier ?elementneedsattention ?elementLabel
WHERE {
?pathway dc:title ?title .
?elementneedsattention a gpml:requiresCurationAttention .
?elementneedsattention dcterms:isPartOf ?pathway .
?elementneedsattention rdfs:label ?elementLabel .
@andrawaag
andrawaag / getSparqlAsRDF.pl
Created July 11, 2013 10:50
Get all mouse pathways. This perl scripts returns the uri through identifiers.org, a link the rdf version of the pathway and a url for the wiki entry of the specific revision currently loading in the triple store of wikipathways
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
my $sparql = "SELECT DISTINCT ?wpIdentifier ?pathway ?page
WHERE {
?pathway dc:title ?title .
?pathway wp:organism ?organism .
?pathway foaf:page ?page .
?pathway dc:identifier ?wpIdentifier .
@andrawaag
andrawaag / countryEducationalInstitutes.sparql
Created July 3, 2013 13:51
Get the list of educationalInstitutes per country
SELECT DISTINCT ?Country count(?EducationalInstitute) as ?noInstitutes
WHERE {
?Country <http://dbpedia.org/property/gdpNominal> ?Nominalgdp .
?Country <http://dbpedia.org/property/gdpNominalYear> ?gdpNominalYear .
?Country <http://dbpedia.org/property/gdpPppPerCapita> ?gdpPppPerCapita .
?Country <http://dbpedia.org/property/gdpPpp> ?gdpPpp .
?EducationalInstitute <http://dbpedia.org/property/country> ?Country .
?EducationalInstitute <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/EducationalOrganization> .} ORDER BY ?noInstitutes
CONSTRUCT {?externalEnsemblId <skos:relatedMatch> ?dbPrimaryAcc .
?dbPrimaryAcc <DC.source> ?dbName .}
WHERE {
?xref a <xref> .
?xref <hasDbprimary_acc> ?dbPrimaryAcc .
?xref <hasDisplayLabel> ?dbDisplayLabel .
?xref <hasExternalDbId> ?externalDbId .
?xref <hasInternalEnsemblId> ?internalEnsemblId .
?externalDbId <hasDbName> ?dbName .
?internalEnsemblId <hasExternalEnsemblId> ?externalEnsemblId .
open DISEASEGENEFILE, "N:/FHML_BIGCAT/Bioinformatics/Programming/mart.txt";
open EXPRESSIONFILE, "N:/FHML_BIGCAT/Bioinformatics/Programming/GeneExpression.txt";;
%disease = {};
while($line = <DISEASEGENEFILE>){
@fields = split(/\t/, $line);
if ($fields[2] ne ''){
$disease{$fields[0]} = $fields[2];
}
}
open EXPRESSIONFILE, "N:/FHML_BIGCAT/Bioinformatics/Programming/GeneExpression.txt";
$counter = 0;
while ($line = <FILE>){
@fields = split('\t', $line);
if ($fields[2]<0){
$counter = $counter + 1;
}
}
print $counter;
@andrawaag
andrawaag / gist:5689819
Created June 1, 2013 09:37
BGKMLW25_task7.pl
open EXPRESSIONFILE, "N:/FHML_BIGCAT/Bioinformatics/Programming/GeneExpression.txt";
while ($line = <FILE>){
@fields = split('\t', $line);
if ($fields[2]<0){
print $line;
}
}
open EXPRESSIONFILE, "N:/FHML_BIGCAT/Bioinformatics/Programming/GeneExpression.txt";
while ($line = <EXPRESSIONFILE>){
@fields = split('\t', $line);
print $fields[9]."\n";
}
%fruitcolor = ("apple", "red", "banana", "yellow", "orange", "orange", "kiwi", "brown");
while (($key, $value) = each(%fruitcolor)){
print "A ". $key." is ".$value."\n";
}
%fruitcolor = ("apple", "red", "banana", "yellow", "orange", "orange", "kiwi", "brown");
print $fruitcolor{"apple"}."\n";
print $fruitcolor{"banana"}."\n";
print $fruitcolor{"orange"}."\n";
print $fruitcolor{"kiwi"}."\n";