@prefix ex: <https://sparql.omabrowser.org/.well-known/sparql-examples/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:11 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "The percentage of proteins in Drosophila melanogaster that has at least one paralogous sequence (protein)."@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX orth: <http://purl.org/net/orth#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT (((xsd:float(?num_paralogy)*100)/xsd:float(?total)) as ?result)
WHERE {
    {
        SELECT (count(distinct ?PROTEIN) as ?num_paralogy )
        WHERE {
            ?cluster a orth:ParalogsCluster.
            ?cluster orth:hasHomologousMember ?node1.
            ?cluster orth:hasHomologousMember ?node2.
            ?node2 orth:hasHomologousMember* ?PROTEIN.
            ?node1 orth:hasHomologousMember* ?IS_PARALOGOUS_TO_PROTEIN.
            ?PROTEIN a orth:Protein.
            ?PROTEIN orth:organism/obo:RO_0002162/up:scientificName ?species.
            ?IS_PARALOGOUS_TO_PROTEIN a orth:Protein.
            ?IS_PARALOGOUS_TO_PROTEIN orth:organism/obo:RO_0002162/up:scientificName ?species .
            values(?species ){( 'Drosophila melanogaster' )}
            filter(?node1 != ?node2)
        }
    }
    {
        SELECT (count(distinct ?protein_total) as ?total)
            WHERE {
               ?protein_total a orth:Protein .
               ?protein_total orth:organism/obo:RO_0002162/up:scientificName ?species .
               values(?species ){( 'Drosophila melanogaster' )}
            }
    }
}""" ;
    schema:target <https://sparql.omabrowser.org/sparql> .

