Skip to content

Instantly share code, notes, and snippets.

def win(clouds):
print(clouds)
now_on = -1
jumps = 0
if clouds[-1] == 1:
print("invalid game! ends with a thunderhead.")
return None
while True:
@sorsaffari
sorsaffari / example-working-with-tweets-pom.xml
Created January 16, 2019 12:10
example-working-with-tweets/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ai.grakn</groupId>
<artifactId>twitterexample</artifactId>
<version>1.0-SNAPSHOT</version>
@sorsaffari
sorsaffari / movies-schema.gql
Created January 7, 2019 14:38
sample-datasets > movies > schema.gql
insert
"production" sub entity
is-abstract
## Filming details
plays production-with-crew
plays production-with-cast
plays production-with-company
plays production-with-location
@sorsaffari
sorsaffari / protein_structure_prediction_rule.gql
Created November 2, 2018 16:49
Protein Structure Prediction: Implied sequence-function-mapping rule
sequence-function-mapping sub relationship,
relates mapping-sequence,
relates mapped-function;
implied-sequence-function-mapping sub rule,
when {
$seq isa sequence;
$struct isa structure;
$func isa function;
(mapping-sequence: $seq, mapped-structure: $struct) isa sequence-structure-mapping;
@sorsaffari
sorsaffari / protein_structure_prediction_query_5.gql
Created November 2, 2018 15:37
Protein Structure Prediction: Get all functions that relate directly or indirectly (via a similar sequence) to a particular sequence
match
$target-sequence isa sequence "MNVGTAHSEVNPNTRVMNSRGIWLSYVLAIGLLHIVLLSIPFVSVPVVWTLTNLIHNMGMYIFLHTVKGTPFETPDQGKARLLTHWEQMDYGVQFTASRKFLTITPIVLYFLTSFYTKYDQIHFVLNTVSLMSVLIPKLPQLHGVRIFGINKY";
$direct-function isa function;
(mapping-sequence: $target-sequence, mapped-function: $direct-function) isa sequence-function-mapping;
$similar-sequence isa sequence;
$alignment (target-sequence: $target-sequence, matched-sequence: $similar-sequence) isa sequence-sequence-alignment;
$alignment has identicality > 0.8;
$indirect-function isa function;
(mapping-sequence: $similar-sequence, mapped-function: $indirect-function) isa sequence-function-mapping;
get $direct-function, $indirect-function;
@sorsaffari
sorsaffari / protein_structure_prediction_query_4.gql
Created November 2, 2018 15:34
Protein Structure Prediction: Get all sequences that have a particular function
match
$target-function isa function "enzyme";
$sequence isa sequence;
(mapping-sequence: $sequence, mapped-function: $target-function) isa sequence-function-mapping;
get $sequence;
@sorsaffari
sorsaffari / protein_structure_prediction_query_3.gql
Last active November 2, 2018 15:29
Protein Structure Prediction: Get all structures of the sequences that have an alignment with a particular sequence (with unknown structure), given that the alignment has an identicality above 80%
match
$target-sequence isa sequence "MNVGTAHSEVNPNTRVMNSRGIWLSYVLAIGLLHIVLLSIPFVSVPVVWTLTNLIHNMGMYIFLHTVKGTPFETPDQGKARLLTHWEQMDYGVQFTASRKFLTITPIVLYFLTSFYTKYDQIHFVLNTVSLMSVLIPKLPQLHGVRIFGINKY";
$similar-sequence isa sequence;
$alignment (target-sequence: $target-sequence, matched-sequence: $similar-sequence) isa sequence-sequence-alignment;
$alignment has identicality > 0.8;
$structure isa structure;
(mapping-sequence: $similar-sequence, mapped-structure: $structure) isa sequence-structure-mapping;
get $structure;
@sorsaffari
sorsaffari / protein_structure_prediction_query_2.gql
Created November 2, 2018 15:25
Protein Structure Prediction: Get all sequences that have a particular structure
match
  $target-structure isa strucuture has pdb-id "2RHC";
  $sequence isa sequence;
  (mapping-sequence: $sequence, mapped-structure: $target-structure) isa sequence-structure-mapping;
get $sequence;
@sorsaffari
sorsaffari / protein_structure_prediction_query_1.gql
Created November 2, 2018 15:19
Protein Structure Prediction: Get all structures of a particular sequence
match
$target-sequence isa sequence "MNVGTAHSEVNPNTRVMNSRGIWLSYVLAIGLLHIVLLSIPFVSVPVVWTLTNLIHNMGMYIFLHTVKGTPFETPDQGKARLLTHWEQMDYGVQFTASRKFLTITPIVLYFLTSFYTKYDQIHFVLNTVSLMSVLIPKLPQLHGVRIFGINKY";
$structure isa structure;
(mapping-sequence: $target-sequence, mapped-structure: $structure) isa sequence-structure-mapping;
get $structure;
@sorsaffari
sorsaffari / XmlMigration.java
Created October 23, 2018 16:39
Migrating XML data into Grakn using the Java client
package ai.grakn.examples;
import ai.grakn.GraknTxType;
import ai.grakn.Keyspace;
import ai.grakn.client.Grakn;
import ai.grakn.util.SimpleURI;
/**
* a lean JSON Library for Java,
* @see <a href="https://bolerio.github.io/mjson/">mjson</a>