<commit_before>
;; obo/MI_0000 ;psi-mi "molecular interaction"
;; obo/INO_0000002 ;interaction

;; obo/GO_ ; complex

`{:name "irefweb-interaction-2-proteins"
  :head ((?/interaction rdfs/subClassOf obo/MI_0000) ;interaction

         (?/r1 rdf/type owl/Restriction)
         (?/r1 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r1 owl/someValuesFrom ?/protein1)

         (?/r2 rdf/type owl/Restriction)
         (?/r2 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r2 owl/someValuesFrom ?/protein2)

         ;;make the interaction be necessarily part of these 3 restrictions
         ;;still need to add a sufficient definition
         (?/interaction rdfs/subClassOf ?/r1)
         (?/interaction rdfs/subClassOf ?/r2))

  :body
  (;; just look this up once we'll need it later
   (_/Ftypename kiao/hasTemplate iaoirefweb/IRefWebInteractorType_interactorTypeNameDataField1)
   (_/Ftypename obo/IAO_0000219 "protein") ; denotes
   (_/Rtype obo/BFO_0000051 _/Ftypename) ; has_part
   (_/Rtype kiao/hasTemplate iaoirefweb/IRefWebInteractorTypeSchema1)


   ;; find all interactions with 2 partners
   (_/fvnum kiao/hasTemplate iaoirefweb/IRefWebInteraction_numParticipantsDataField1)
   ;;(_/fvnum obo/IAO_0000219 ["2" xsd/integer])
   (_/fvnum obo/IAO_0000219 2) ; denotes
   (_/interactionrecord obo/BFO_0000051 _/fvnum) ; has_part

   ;; get top record
   (_/psimi obo/BFO_0000051 _/interactionrecord) ; has_part

   ;;get two distinct interactors
   (_/psimi obo/BFO_0000051 ?/Rinteractor1) ; has_part
   (?/Rinteractor1 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)
   (_/psimi obo/BFO_0000051 ?/Rinteractor2) ; has_part
   (?/Rinteractor2 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)
   (!= ?/Rinteractor1 ?/Rinteractor2)

   ;;all two part interactions should be protein and protein but verify
   ;; reuse type from initial lookup
   (?/Rinteractor1 obo/BFO_0000051 _/Rtype) ; has_part
   (?/Rinteractor2 obo/BFO_0000051 _/Rtype) ; has_part

   ;;get the first interactor ID and then BIO entity
   (?/Rinteractor1 obo/BFO_0000051 _/FID1) ; has_part
   (_/FID1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (_/FID1 obo/IAO_0000219 _/ID1) ; denotes
   (_/ID1 obo/IAO_0000219 ?/protein1) ; denotes

   ;;get the second interactor ID and then BIO entity
   (?/Rinteractor2 obo/BFO_0000051 _/FID2) ; has_part
   (_/FID2 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (_/FID2 obo/IAO_0000219 _/ID2) ; denotes
   (_/ID2 obo/IAO_0000219 ?/protein2) ; denotes
   )


 ;;need a better way to reify / sort the restrictions to form the interaction

  :reify ([?/interaction {:ln (:sha-1 "interaction" ?/r1 ?/r2)
                          :ns "kbio" :prefix "I_"}]
          [?/r1 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/r2 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
 }

`{:name "irefweb-reify-complex-and-interaction"
  :head ((?/interaction rdfs/subClassOf obo/MI_0000) ;interaction
         (?/complex rdfs/subClassOf obo/GO_0032991)  ;macromolecular complex
         (?/interaction kro/resuts_in_the_formation_of ?/complex)

         (?/complexID obo/IAO_0000219 ?/complex) ; complexID denotes complex
         ;;(?/complexID obo/IAO_0000142 ?/interaction) ;the complex id mentions the interaction? no
         )
  :body
  ((_/Ftypename kiao/hasTemplate iaoirefweb/IRefWebInteractorType_interactorTypeNameDataField1)
   (_/Ftypename obo/IAO_0000219 "protein complex") ; denotes
   (_/Rtype obo/BFO_0000051 _/Ftypename) ; has_part
   (_/Rtype kiao/hasTemplate iaoirefweb/IRefWebInteractorTypeSchema1)

   ;;get all the interactor records that are protein complex stand-ins
   (?/Rinteractor obo/BFO_0000051 _/Rtype) ; has_part

   ;;get the complex ID
   (?/Rinteractor obo/BFO_0000051 _/FID1) ; has_part
   (_/FID1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (_/FID1 obo/IAO_0000219 ?/complexID)) ; denotes

  :reify ([?/interaction {:ln (:sha-1 "interaction" ?/complexID)
                          :ns "kbio" :prefix "I_"}]
          [?/complex {:ln (:sha-1 "complex" ?/complexID)
                      :ns "kbio" :prefix "C_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
  }


`{:name "irefweb-complex-and-interaction-participant"
  :head (;(?/interaction rdfs/subClassOf obo/MI_0000) ;interaction
         ;(?/complex rdfs/subClassOf obo/GO_0032991)  ;macromolecular complex
         (?/r1 rdf/type owl/Restriction)
         (?/r1 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r1 owl/someValuesFrom ?/protein)

         (?/r2 rdf/type owl/Restriction)
         (?/r2 owl/onProperty obo/BFO_0000051) ; has_part
         (?/r2 owl/someValuesFrom ?/protein)

         (?/interaction rdfs/subClassOf ?/r1)
         (?/complex rdfs/subClassOf ?/r2))
  ;;how to possibly extend these to sufficient definitions?

  :body
  (;; just look this up once we'll need it later
   (_/FtypenameP kiao/hasTemplate iaoirefweb/IRefWebInteractorType_interactorTypeNameDataField1)
   (_/FtypenameP obo/IAO_0000219 "protein") ; denotes
   (_/RtypeP obo/BFO_0000051 _/FtypenameP) ; has_part
   (_/RtypeP kiao/hasTemplate iaoirefweb/IRefWebInteractorTypeSchema1)

   ;;get the protein complex type
   (_/FtypenamePC kiao/hasTemplate iaoirefweb/IRefWebInteractorType_interactorTypeNameDataField1)
   (_/FtypenamePC obo/IAO_0000219 "protein complex")  ; denotes
   (_/RtypePC obo/BFO_0000051 _/FtypenamePC) ; has_part
   (_/RtypePC kiao/hasTemplate iaoirefweb/IRefWebInteractorTypeSchema1)

   ;;get all the protein complex interaction records
   (?/RinteractorPC obo/BFO_0000051 _/RtypePC) ; has_part
   (_/psimi obo/BFO_0000051 ?/RinteractorPC) ; has_part

   ;;get the one protein mentioned in this record
   (_/psimi obo/BFO_0000051 ?/RinteractorP) ; has_part
   (?/RinteractorP obo/BFO_0000051 _/RtypeP) ; has_part

   ;;get the first interactor ID and then BIO entity
   (?/RinteractorPC obo/BFO_0000051 _/FID1) ; has_part
   (_/FID1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (_/FID1 obo/IAO_0000219 ?/complexID) ; denotes

   ;;get the second interactor ID and then BIO entity
   (?/RinteractorP obo/BFO_0000051 _/FID2) ; has_part
   (_/FID2 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (_/FID2 obo/IAO_0000219 _/ID2) ; denotes
   (_/ID2 obo/IAO_0000219 ?/protein)) ; denotes

  :reify ([?/interaction {:ln (:sha-1 "interaction" ?/complexID)
                          :ns "kbio" :prefix "I_"}]
          [?/complex {:ln (:sha-1 "complex" ?/complexID)
                      :ns "kbio" :prefix "C_"}]
          [?/r1 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/r2 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
 }
<commit_msg>revised irefweb rules to represent protein interactions<commit_after>
`{:name "irefweb-binary-interactions"
  :description ""
  :head ((?/interaction rdfs/subClassOf ?/int_type_id) ;interaction

         ;; create subclasses of the proteins
         (?/protein1_sc rdfs/subClassOf ?/protein1)
         (?/protein2_sc rdfs/subClassOf ?/protein2)

         (?/r1 rdf/type owl/Restriction)
         (?/r1 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r1 owl/someValuesFrom ?/protein1_sc)

         (?/r2 rdf/type owl/Restriction)
         (?/r2 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r2 owl/someValuesFrom ?/protein2_sc)

         (?/interaction rdfs/subClassOf ?/r1)
         (?/interaction rdfs/subClassOf ?/r2))

  :body
  ;; get binary interaction records
  ((?/edge_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_edgeTypeDataField1)
   (?/edge_field obo/IAO_0000219 "X"@en)   ;; "X" signifies binary interaction
   (?/interaction_record obo/BFO_0000051 ?/edge_field)  ;; bfo/has_part

   ;; get the unique interaction identifier
   (?/interaction_record obo/BFO_0000051 ?/interaction_checksum_field) ;; bfo/has_part
   (?/interaction_checksum_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_checksumInteractionDataField1)
   (?/interaction_checksum_field obo/IAO_0000219 ?/unique_interaction_id) ;; iao/denotes

   ;; get the interaction type name and ID
   (?/interaction_record obo/BFO_0000051 ?/interaction_type_record) ;; bfo/has_part
   (?/interaction_type_record kiao/hasTemplate iaoirefweb/IRefWebInteractionTypeSchema1)
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_name_field) ;; bfo/has_part
   (?/int_type_name_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeNameDataField1)
   (?/int_type_name_field obo/IAO_0000219 ?/int_type_name) ;; iao/denotes
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_id_field) ;; bfo/has_part
   (?/int_type_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeIdDataField1)
   (?/int_type_id_field obo/IAO_0000219 ?/int_type_id_ice) ;; iao/denotes
   (?/int_type_id_ice obo/IAO_0000219 ?/int_type_id) ;; iao/denotes

   ;; get the detection method
   (?/interaction_record obo/BFO_0000051 ?/interaction_detection_method_record) ;; bfo/has_part
   (?/interaction_detection_method_record kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethodSchema1)
   (?/interaction_detection_method_record obo/BFO_0000051 ?/detection_method_id_field) ;; bfo/has_part
   (?/detection_method_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethod_detectionMethodIdDataField1)
   (?/detection_method_id_field obo/IAO_0000219 ?/detection_method_id) ;; iao/denotes

   ;; there is a "super" record in IRefWeb that contains references
   ;; to the interaction record and interactor record(s)
   (?/super_record obo/BFO_0000051 ?/interaction_record) ;; bfo/has_part

   ;; get the two distinct interactors for this binary interaction
   (?/super_record obo/BFO_0000051 ?/interactor_record1) ;; bfo/has_part
   (?/interactor_record1 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)
   (?/super_record obo/BFO_0000051 ?/interactor_record2) ;; bfo/has_part
   (?/interactor_record2 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)
   (!= ?/interactor_record1 ?/interactor_record2)

   ;; get the bioentity (protein) corresponding to interactor 1
   (?/interactor_record1 obo/BFO_0000051 ?/id_field1) ;; bfo/has_part
   (?/id_field1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (?/id_field1 obo/IAO_0000219 ?/id1) ;; iao/denotes
   (?/id1 obo/IAO_0000219 ?/protein1) ;; iao/denotes

   ;; get the bioentity (protein) corresponding to interactor 2
   (?/interactor_record2 obo/BFO_0000051 ?/id_field2) ;; bfo/has_part
   (?/id_field2 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (?/id_field2 obo/IAO_0000219 ?/id2) ;; iao/denotes
   (?/id2 obo/IAO_0000219 ?/protein2)) ;; iao/denotes

  ;; we take advantage of the fact that IRefWeb has
  ;; created a unique id for the interaction. This will allow us to reproducibly create
  ;; a hash for the interaction that can be matched across records.
  :reify ([?/interaction {:ln (:sha-1 ?/unique_interaction_id)
                          :ns "kbio" :prefix "I_"}]
          [?/r1 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/r2 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/protein1_sc {:ln (:sha-1 ?/interaction ?/protein1)
                          :ns "kbio" :prefix "P_"}]
          [?/protein2_sc {:ln (:sha-1 ?/interaction ?/protein2)
                          :ns "kbio" :prefix "P_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
  }



`{:name "irefweb-unary-interactions"
  :description ""
  :head ((?/interaction rdfs/subClassOf ?/int_type_id) ;interaction

         ;; create subclasses of the single protein involved
         (?/protein1_sc rdfs/subClassOf ?/protein1)

         (?/r1 rdf/type owl/Restriction)
         (?/r1 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r1 owl/someValuesFrom ?/protein1_sc)

         (?/interaction rdfs/subClassOf ?/r1))

  :body
  ;; get binary interaction records
  ((?/edge_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_edgeTypeDataField1)
   (?/edge_field obo/IAO_0000219 "Y"@en)   ;; "Y" signifies intra-molecular interaction
   (?/interaction_record obo/BFO_0000051 ?/edge_field)  ;; bfo/has_part

   ;; get the unique interaction identifier
   (?/interaction_record obo/BFO_0000051 ?/interaction_checksum_field) ;; bfo/has_part
   (?/interaction_checksum_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_checksumInteractionDataField1)
   (?/interaction_checksum_field obo/IAO_0000219 ?/unique_interaction_id) ;; iao/denotes

   ;; get the interaction type name and ID
   (?/interaction_record obo/BFO_0000051 ?/interaction_type_record) ;; bfo/has_part
   (?/interaction_type_record kiao/hasTemplate iaoirefweb/IRefWebInteractionTypeSchema1)
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_name_field) ;; bfo/has_part
   (?/int_type_name_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeNameDataField1)
   (?/int_type_name_field obo/IAO_0000219 ?/int_type_name) ;; iao/denotes
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_id_field) ;; bfo/has_part
   (?/int_type_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeIdDataField1)
   (?/int_type_id_field obo/IAO_0000219 ?/int_type_id_ice) ;; iao/denotes
   (?/int_type_id_ice obo/IAO_0000219 ?/int_type_id) ;; iao/denotes

   ;; get the detection method
   (?/interaction_record obo/BFO_0000051 ?/interaction_detection_method_record) ;; bfo/has_part
   (?/interaction_detection_method_record kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethodSchema1)
   (?/interaction_detection_method_record obo/BFO_0000051 ?/detection_method_id_field) ;; bfo/has_part
   (?/detection_method_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethod_detectionMethodIdDataField1)
   (?/detection_method_id_field obo/IAO_0000219 ?/detection_method_id) ;; iao/denotes

   ;; there is a "super" record in IRefWeb that contains references
   ;; to the interaction record and interactor record(s)
   (?/super_record obo/BFO_0000051 ?/interaction_record) ;; bfo/has_part

   ;; there is only one interactor for the unary interaction
   (?/super_record obo/BFO_0000051 ?/interactor_record1) ;; bfo/has_part
   (?/interactor_record1 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)

   ;; get the bioentity (protein) corresponding to interactor 1
   (?/interactor_record1 obo/BFO_0000051 ?/id_field1) ;; bfo/has_part
   (?/id_field1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (?/id_field1 obo/IAO_0000219 ?/id1) ;; iao/denotes
   (?/id1 obo/IAO_0000219 ?/protein1)) ;; iao/denotes

  ;; we take advantage of the fact that IRefWeb has
  ;; created a unique id for the interaction. This will allow us to reproducibly create
  ;; a hash for the interaction that can be matched across records.
  :reify ([?/interaction {:ln (:sha-1 ?/unique_interaction_id)
                          :ns "kbio" :prefix "I_"}]
          [?/r1 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/protein1_sc {:ln (:sha-1 ?/interaction ?/protein1)
                          :ns "kbio" :prefix "P_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
  }



`{:name "irefweb-n-ary-interactions"
  :description "interactions with >2 participants. IRefWeb refers to them as complexes,
  but these interactions don't necessarily form complexes."
  :head ((?/interaction rdfs/subClassOf ?/int_type_id) ;interaction

         ;; create subclasses of the proteins
         (?/protein1_sc rdfs/subClassOf ?/protein1)

         (?/r1 rdf/type owl/Restriction)
         (?/r1 owl/onProperty obo/RO_0000057) ; has_participant
         (?/r1 owl/someValuesFrom ?/protein1_sc)

         (?/interaction rdfs/subClassOf ?/r1))

  :body
  ;; get binary interaction records
  ((?/edge_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_edgeTypeDataField1)
   (?/edge_field obo/IAO_0000219 "C"@en)   ;; "C" signifies "complex" in IRefWeb, but really mean n-ary interaction where n>2
   (?/interaction_record obo/BFO_0000051 ?/edge_field)  ;; bfo/has_part

   ;; get the unique interaction identifier
   (?/interaction_record obo/BFO_0000051 ?/interaction_checksum_field) ;; bfo/has_part
   (?/interaction_checksum_field kiao/hasTemplate iaoirefweb/IRefWebInteraction_checksumInteractionDataField1)
   (?/interaction_checksum_field obo/IAO_0000219 ?/unique_interaction_id) ;; iao/denotes

   ;; get the interaction type name and ID
   (?/interaction_record obo/BFO_0000051 ?/interaction_type_record) ;; bfo/has_part
   (?/interaction_type_record kiao/hasTemplate iaoirefweb/IRefWebInteractionTypeSchema1)
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_name_field) ;; bfo/has_part
   (?/int_type_name_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeNameDataField1)
   (?/int_type_name_field obo/IAO_0000219 ?/int_type_name) ;; iao/denotes
   (?/interaction_type_record obo/BFO_0000051 ?/int_type_id_field) ;; bfo/has_part
   (?/int_type_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionType_interactionTypeIdDataField1)
   (?/int_type_id_field obo/IAO_0000219 ?/int_type_id_ice) ;; iao/denotes
   (?/int_type_id_ice obo/IAO_0000219 ?/int_type_id) ;; iao/denotes

   ;; get the detection method
   (?/interaction_record obo/BFO_0000051 ?/interaction_detection_method_record) ;; bfo/has_part
   (?/interaction_detection_method_record kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethodSchema1)
   (?/interaction_detection_method_record obo/BFO_0000051 ?/detection_method_id_field) ;; bfo/has_part
   (?/detection_method_id_field kiao/hasTemplate iaoirefweb/IRefWebInteractionDetectionMethod_detectionMethodIdDataField1)
   (?/detection_method_id_field obo/IAO_0000219 ?/detection_method_id) ;; iao/denotes

   ;; there is a "super" record in IRefWeb that contains references
   ;; to the interaction record and interactor record(s)
   (?/super_record obo/BFO_0000051 ?/interaction_record) ;; bfo/has_part

   ;; there are two interactors, but one is a place holder that is used to bind
   ;; multiple records together to form n-ary interactions. The placeholder is
   ;; identical to the unique interaction ID, so we select the other interactor
   ;; (which will be linked to a bioentity (protein))
   (?/super_record obo/BFO_0000051 ?/interactor_record1) ;; bfo/has_part
   (?/interactor_record1 kiao/hasTemplate iaoirefweb/IRefWebInteractorSchema1)

   ;; get the bioentity (protein) corresponding to interactor 1
   (?/interactor_record1 obo/BFO_0000051 ?/id_field1) ;; bfo/has_part
   (?/id_field1 kiao/hasTemplate iaoirefweb/IRefWebInteractor_uniqueIdDataField1)
   (?/id_field1 obo/IAO_0000219 ?/id1) ;; iao/denotes
   (!= ?/id1 ?/unique_interaction_id)
   (?/id1 obo/IAO_0000219 ?/protein1)) ;; iao/denotes

  ;; we take advantage of the fact that IRefWeb has
  ;; created a unique id for the interaction. This will allow us to reproducibly create
  ;; a hash for the interaction that can be matched across records.
  :reify ([?/interaction {:ln (:sha-1 ?/unique_interaction_id)
                          :ns "kbio" :prefix "I_"}]
          [?/r1 {:ln (:restriction)
                 :ns "kbio" :prefix "R_"}]
          [?/protein1_sc {:ln (:sha-1 ?/interaction ?/protein1)
                          :ns "kbio" :prefix "P_"}])

  :options {:magic-prefixes [["franzOption_clauseReorderer" "franz:identity"]]}
  }

{'fraction_non_alphanumeric': 0.11114485271788642, 'fraction_numerical': 0.04833485170563822, 'mean_word_length': 3.9200697211155378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '263925', 'n_tokens_mistral': 8053, 'n_tokens_neox': 6986, 'n_words': 1429}