Giter VIP home page Giter VIP logo

Comments (2)

egonw avatar egonw commented on July 29, 2024

I need to think about this a bit more. I like the idea, but need to overthink the implications.

from scholia.

Adafede avatar Adafede commented on July 29, 2024

I also overthought again about it, and here is what came to my mind (WIP):

So keeping the same table but with an additional column, being "stereoisomer, isotopomer, etc." based on the matching layers:

PREFIX target: <http://www.wikidata.org/entity/Q41576>

# title: related chemical structures
SELECT ?mol ?molLabel ?InChI ?InChIKey ?CAS ?ChemSpider ?PubChem_CID ?layer_b ?layer_t ?layer_m ?layer_s WITH {
  SELECT ?queryKey ?srsearch ?filter WHERE {
    target: wdt:P235 ?queryKey .
    BIND(CONCAT(SUBSTR($queryKey,1,14), " haswbstatement:P235") AS ?srsearch)
    BIND(CONCAT("^", SUBSTR($queryKey,1,14)) AS ?filter)
  }
} AS %MOLS WITH {
  SELECT ?mol ?InChIKey WHERE {
    INCLUDE %MOLS
    SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "www.wikidata.org";
        wikibase:api "Search";
        mwapi:srsearch ?srsearch;
        mwapi:srlimit "max".
        ?mol wikibase:apiOutputItem mwapi:title.
      }
    ?mol wdt:P235 ?InChIKey .
    FILTER (REGEX(STR(?InChIKey), ?filter))
    FILTER (?InChIKey != ?queryKey)
  }
} AS %MOLS2 {
  INCLUDE %MOLS2
  ?mol wdt:P234 ?InChI .
  # WIP
  BIND(REPLACE(?InChI, "/{0}.*?/b", "/") AS ?layer_b)
  BIND(REPLACE(?InChI, "/{0}.*?/t", "/") AS ?layer_t)
  BIND(REPLACE(?InChI, "/{0}.*?/m", "/") AS ?layer_m)
  BIND(REPLACE(?InChI, "/{0}.*?/s", "/") AS ?layer_s)
  OPTIONAL { ?mol wdt:P231 ?CAS }
  OPTIONAL { ?mol wdt:P661 ?ChemSpider }
  OPTIONAL { ?mol wdt:P662 ?PubChem_CID }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

from scholia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.