% David van Dijk 2010 - University of Amsterdam, Section Computational Science % motif1: hiv - human - hiv motif1(NN1, NN2, NN3, I1, I2) :- e(N1, N2, I1,_), e(N3, N2, I2,_), N1 \= N3, n(N1, 'type', 'hiv',_), n(N2, 'type', 'human',_), n(N3, 'type', 'hiv',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3), (I1 \= I2 | is_smaller(N1, N3)). % prevent finding symmetric motifs twice % motif2: hiv - human motif2(NN1, NN2, I1, I2) :- e(N1, N2, I1,_), e(N1, N2, I2,_), n(N1, 'type', 'hiv',_), n(N2, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), simplename(CNN1, NN1), simplename(CNN2, NN2). % motif3: hiv - human % | | % human - hiv motif3(NN1, NN2, NN3, NN4, I1, I2, I3, I4):- e(N1, N2, I1,_), e(N3, N2, I2,_), e(N3, N4, I3,_), e(N1, N4, I4,_), N1 \= N3, N2 \= N4, n(N1, 'type', 'hiv',_), n(N2, 'type', 'human',_), n(N3, 'type', 'hiv',_), n(N4, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), n(N4, 'Prot_Name', CNN4,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3), simplename(CNN4, NN4). % motif4: hiv % / | \ % human human human % \ | / % hiv motif4(NN1, NN2, NN3, NN4, NN5, I1, I2, I3, I4, I5, I6) :- e(N1, N3, I1,_), e(N1, N4, I2,_), e(N2, N4, I3,_), e(N2, N3, I4,_), e(N3, N5, I5,_), e(N4, N5, I6,_), N1 \= N2, N3 \= N4, N1 \= N5, N2 \= N5, n(N1, 'type', 'human',_), n(N2, 'type', 'human',_), n(N3, 'type', 'hiv',_), n(N4, 'type', 'hiv',_), n(N5, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), n(N4, 'Prot_Name', CNN4,_), n(N5, 'Prot_Name', CNN5,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3), simplename(CNN4, NN4), simplename(CNN5, NN5). % motif5: human - hiv - human % asymmetric motif5(NN1, NN2, NN3, I1, I2) :- e(N2, N1, I1,_), e(N2, N3, I2,_), N1 \= N3, I1 \= I2, n(N1, 'type', 'human',_), n(N2, 'type', 'hiv',_), n(N3, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3). % motif5: human - hiv - human % symmetric -> force order on human nodes so only one motif will be found motif5(NN1, NN2, NN3, I, I) :- e(N2, N1, I,_), e(N2, N3, I,_), N1 \= N3, is_smaller(N1, N3), n(N1, 'type', 'human',_), n(N2, 'type', 'hiv',_), n(N3, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3). % motif6: hiv % / \ % human - human % symmetric motif6(NN1, NN2, NN3, I, I) :- e(N2, N1, I,_), e(N2, N3, I,_), e(N1, N3,_,_), N1 \= N3, n(N1, 'type', 'human',_), n(N2, 'type', 'hiv',_), n(N3, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3). % motif6: hiv % / \ % human - human % asymmetric -> make human-human interaction bidirectional so all motifs will be found % this is becasue undirected human-human edges are defined as directed edges motif6(NN1, NN2, NN3, I1, I2) :- e(N2, N1, I1,_), e(N2, N3, I2,_), I1 \= I2, N1 \= N3, (e(N1, N3,_,_) | e(N3, N1,_,_)), n(N1, 'type', 'human',_), n(N2, 'type', 'hiv',_), n(N3, 'type', 'human',_), n(N1, 'Prot_Name', CNN1,_), n(N2, 'Prot_Name', CNN2,_), n(N3, 'Prot_Name', CNN3,_), simplename(CNN1, NN1), simplename(CNN2, NN2), simplename(CNN3, NN3). % writeList: write list to file writeList(_, []). writeList(File, [H|T]) :- writeElement(File, H), writeList(File, T). writeElement(File, M) :- open(File, append, Stream), write(Stream, M), nl(Stream), close(Stream). % switch: switch edges switch(E1, E2) :- E1 \= E2, e(N1, N3, I1, E1), e(N2, N4, I2, E2), retract(e(N1, N3, I1, E1)), retract(e(N2, N4, I2, E2)), assert(e(N1, N4, I1, E1)), assert(e(N2, N3, I2, E2)). % switch2: replace edge E with edge from Ni1 to Ni2 switch2(E, Ni1, Ni2) :- e(N1, N2, I, E), n(Nhiv, 'type', 'hiv', Ni1), n(Nhuman, 'type', 'human', Ni2), retract(e(N1, N2, I, E)), assert(e(Nhiv, Nhuman, I, E)). % switch3: switch edges, but also switch interactions switch3(E1, E2) :- E1 \= E2, e(N1, N3, I1, E1), e(N2, N4, I2, E2), retract(e(N1, N3, I1, E1)), retract(e(N2, N4, I2, E2)), assert(e(N1, N4, I2, E1)), assert(e(N2, N3, I1, E2)). % todirect: assert direct interaction for indirect interaction: hiv-human-hiv => hiv-hiv todirect :- e(N1, N2, I1, _), e(N3, N2, I2, _), N1 \= N3, (I1 == 'activates'|I1 == 'inhibits'), (I2 == 'activated by'|I2 == 'inhibited by'), n(N1, 'type', 'hiv',_), n(N2, 'type', 'human',_), n(N3, 'type', 'hiv',_), assert(e(N1, N3, 'indirectly_signals', 8888888)). % nettodirect: for all hiv-human-hiv assert hiv-hiv nettodirect :- findall(_,todirect,_). % indirectnettocsv: write all 'indirectly_signals' interactions to file indirectnettocsv(File) :- findall((NN1:NN2), (e(N1,N2,'indirectly_signals',_),n(N1,'Prot_Name',NN1,_),n(N2,'Prot_Name',NN2,_)),L), writeList(File, L). % switch4: switch or switch3 switch4(E1, E2) :- R is random(2), switch4(E1, E2, R). switch4(E1, E2, 0) :- switch(E1, E2). switch4(E1, E2, 1) :- switch3(E1, E2). % randomize2: % A --1--> B ==> C --1--> D randomize2(0). randomize2(N) :- numedges(NE), numhivnodes(Nhiv), numhumannodes(Nhuman), E is random(NE), N1 is random(Nhiv), N2 is random(Nhuman)+Nhiv, (switch2(E, N1, N2)|true), N3 is N - 1, randomize2(N3). % randomize3: % A --1--> B A --1--> D % ==> % C --2--> D C --2--> B % or % A --1--> B A --2--> D % ==> % C --2--> D C --1--> B randomize3(0). randomize3(N) :- numedges(NE), E1 is random(NE), E2 is random(NE), (switch4(E1, E2)|true), N2 is N - 1, randomize3(N2). % randomize: % A --1--> B A --1--> D % ==> % C --2--> D C --2--> B randomize(0). randomize(N) :- numedges(NE), E1 is random(NE), E2 is random(NE), (switch(E1, E2)|true), N2 is N - 1, randomize(N2). % initnetwork: initialize network with nodes and edges initnetwork :- retractall(e(_,_,_,_)), retractall(n(_,_,_)), consult(signetwork). % gomotif1: find GO annotation for motif1 gomotif1(File, I1, I2) :- concat(File, 'BP', FileBP), concat(File, 'CC', FileCC), concat(File, 'MF', FileMF), findall(BP, (motif1(_,N2,_,I1,I2),n(N2,'BIOLOGICAL_PROCESS',BP,_)), LBP), findall(CC, (motif1(_,N2,_,I1,I2),n(N2,'CELLULAR_COMPONENT',CC,_)), LCC), findall(MF, (motif1(_,N2,_,I1,I2),n(N2,'MOLECULAR_FUNCTION',MF,_)), LMF), length(LBP,NBP), writeElement(FileBP,NBP), writeList(FileBP,LBP), length(LCC,NCC), writeElement(FileCC,NCC), writeList(FileCC,LCC), length(LMF,NMF), writeElement(FileMF,NMF), writeList(FileMF,LMF). % gomotif2: find GO annotation for motif2 gomotif2(File, I1, I2) :- concat(File, 'BP', FileBP), concat(File, 'CC', FileCC), concat(File, 'MF', FileMF), findall(BP, (motif2(_,N2,I1,I2),n(N2,'BIOLOGICAL_PROCESS',BP,_)), LBP), findall(CC, (motif2(_,N2,I1,I2),n(N2,'CELLULAR_COMPONENT',CC,_)), LCC), findall(MF, (motif2(_,N2,I1,I2),n(N2,'MOLECULAR_FUNCTION',MF,_)), LMF), length(LBP,NBP), writeElement(FileBP,NBP), writeList(FileBP,LBP), length(LCC,NCC), writeElement(FileCC,NCC), writeList(FileCC,LCC), length(LMF,NMF), writeElement(FileMF,NMF), writeList(FileMF,LMF). % gomotif5: find GO annotation for motif5 gomotif5(File, I1, I2) :- concat(File, 'BP1', FileBP1), concat(File, 'CC1', FileCC1), concat(File, 'MF1', FileMF1), concat(File, 'BP2', FileBP2), concat(File, 'CC2', FileCC2), concat(File, 'MF2', FileMF2), findall(BP1, (motif5(N1,_,_,I1,I2),n(N1,'BIOLOGICAL_PROCESS',BP1,_)), LBP1), findall(CC1, (motif5(N1,_,_,I1,I2),n(N1,'CELLULAR_COMPONENT',CC1,_)), LCC1), findall(MF1, (motif5(N1,_,_,I1,I2),n(N1,'MOLECULAR_FUNCTION',MF1,_)), LMF1), findall(BP2, (motif5(_,_,N3,I1,I2),n(N3,'BIOLOGICAL_PROCESS',BP2,_)), LBP2), findall(CC2, (motif5(_,_,N3,I1,I2),n(N3,'CELLULAR_COMPONENT',CC2,_)), LCC2), findall(MF2, (motif5(_,_,N3,I1,I2),n(N3,'MOLECULAR_FUNCTION',MF2,_)), LMF2), length(LBP1,NBP1), writeElement(FileBP1,NBP1), writeList(FileBP1,LBP1), length(LCC1,NCC1), writeElement(FileCC1,NCC1), writeList(FileCC1,LCC1), length(LMF1,NMF1), writeElement(FileMF1,NMF1), writeList(FileMF1,LMF1), length(LBP2,NBP2), writeElement(FileBP2,NBP2), writeList(FileBP2,LBP2), length(LCC2,NCC2), writeElement(FileCC2,NCC2), writeList(FileCC2,LCC2), length(LMF2,NMF2), writeElement(FileMF2,NMF2), writeList(FileMF2,LMF2). % gomotif5-1: find GO annotation for motif5-1 gomotif51(File, I1, I2) :- concat(File, 'BP-1', FileBP1), concat(File, 'CC-1', FileCC1), concat(File, 'MF-1', FileMF1), findall(BP1, (motif5(N1,_,_,I1,I2),n(N1,'BIOLOGICAL_PROCESS',BP1,_)), LBP1), findall(CC1, (motif5(N1,_,_,I1,I2),n(N1,'CELLULAR_COMPONENT',CC1,_)), LCC1), findall(MF1, (motif5(N1,_,_,I1,I2),n(N1,'MOLECULAR_FUNCTION',MF1,_)), LMF1), length(LBP1,NBP1), writeElement(FileBP1,NBP1), writeList(FileBP1,LBP1), length(LCC1,NCC1), writeElement(FileCC1,NCC1), writeList(FileCC1,LCC1), length(LMF1,NMF1), writeElement(FileMF1,NMF1), writeList(FileMF1,LMF1). % gomotif5-2: find GO annotation for motif5-2 gomotif52(File, I1, I2) :- concat(File, 'BP-2', FileBP2), concat(File, 'CC-2', FileCC2), concat(File, 'MF-2', FileMF2), findall(BP2, (motif5(_,_,N3,I1,I2),n(N3,'BIOLOGICAL_PROCESS',BP2,_)), LBP2), findall(CC2, (motif5(_,_,N3,I1,I2),n(N3,'CELLULAR_COMPONENT',CC2,_)), LCC2), findall(MF2, (motif5(_,_,N3,I1,I2),n(N3,'MOLECULAR_FUNCTION',MF2,_)), LMF2), length(LBP2,NBP2), writeElement(FileBP2,NBP2), writeList(FileBP2,LBP2), length(LCC2,NCC2), writeElement(FileCC2,NCC2), writeList(FileCC2,LCC2), length(LMF2,NMF2), writeElement(FileMF2,NMF2), writeList(FileMF2,LMF2). % gomotif6: find GO annotation for motif6 gomotif6(File, I1, I2) :- concat(File, 'BP1', FileBP1), concat(File, 'CC1', FileCC1), concat(File, 'MF1', FileMF1), concat(File, 'BP2', FileBP2), concat(File, 'CC2', FileCC2), concat(File, 'MF2', FileMF2), findall(BP1, (motif6(N1,_,_,I1,I2),n(N1,'BIOLOGICAL_PROCESS',BP1,_)), LBP1), findall(CC1, (motif6(N1,_,_,I1,I2),n(N1,'CELLULAR_COMPONENT',CC1,_)), LCC1), findall(MF1, (motif6(N1,_,_,I1,I2),n(N1,'MOLECULAR_FUNCTION',MF1,_)), LMF1), findall(BP2, (motif6(_,_,N3,I1,I2),n(N3,'BIOLOGICAL_PROCESS',BP2,_)), LBP2), findall(CC2, (motif6(_,_,N3,I1,I2),n(N3,'CELLULAR_COMPONENT',CC2,_)), LCC2), findall(MF2, (motif6(_,_,N3,I1,I2),n(N3,'MOLECULAR_FUNCTION',MF2,_)), LMF2), length(LBP1,NBP1), writeElement(FileBP1,NBP1), writeList(FileBP1,LBP1), length(LCC1,NCC1), writeElement(FileCC1,NCC1), writeList(FileCC1,LCC1), length(LMF1,NMF1), writeElement(FileMF1,NMF1), writeList(FileMF1,LMF1), length(LBP2,NBP2), writeElement(FileBP2,NBP2), writeList(FileBP2,LBP2), length(LCC2,NCC2), writeElement(FileCC2,NCC2), writeList(FileCC2,LCC2), length(LMF2,NMF2), writeElement(FileMF2,NMF2), writeList(FileMF2,LMF2). % gomotif6-1: find GO annotation for motif6-1 gomotif61(File, I1, I2) :- concat(File, 'BP-1', FileBP1), concat(File, 'CC-1', FileCC1), concat(File, 'MF-1', FileMF1), findall(BP1, (motif6(N1,_,_,I1,I2),n(N1,'BIOLOGICAL_PROCESS',BP1,_)), LBP1), findall(CC1, (motif6(N1,_,_,I1,I2),n(N1,'CELLULAR_COMPONENT',CC1,_)), LCC1), findall(MF1, (motif6(N1,_,_,I1,I2),n(N1,'MOLECULAR_FUNCTION',MF1,_)), LMF1), length(LBP1,NBP1), writeElement(FileBP1,NBP1), writeList(FileBP1,LBP1), length(LCC1,NCC1), writeElement(FileCC1,NCC1), writeList(FileCC1,LCC1), length(LMF1,NMF1), writeElement(FileMF1,NMF1), writeList(FileMF1,LMF1). % gomotif6-2: find GO annotation for motif6-2 gomotif62(File, I1, I2) :- concat(File, 'BP-2', FileBP2), concat(File, 'CC-2', FileCC2), concat(File, 'MF-2', FileMF2), findall(BP2, (motif6(_,_,N3,I1,I2),n(N3,'BIOLOGICAL_PROCESS',BP2,_)), LBP2), findall(CC2, (motif6(_,_,N3,I1,I2),n(N3,'CELLULAR_COMPONENT',CC2,_)), LCC2), findall(MF2, (motif6(_,_,N3,I1,I2),n(N3,'MOLECULAR_FUNCTION',MF2,_)), LMF2), length(LBP2,NBP2), writeElement(FileBP2,NBP2), writeList(FileBP2,LBP2), length(LCC2,NCC2), writeElement(FileCC2,NCC2), writeList(FileCC2,LCC2), length(LMF2,NMF2), writeElement(FileMF2,NMF2), writeList(FileMF2,LMF2). % gomotifs: find GO annotaions for the motifs gomotifs :- gomotifs1, gomotifs2, gomotifs51, gomotifs61, gomotifs52, gomotifs62. gomotifs1 :- % hiv - human - hiv gomotif1('sigmotifs/GO/motif1', 'sig by','sig by'), gomotif1('sigmotifs/GO/motif3', 'activated by','activated by'), gomotif1('sigmotifs/GO/motif4', 'inhibited by','inhibited by'), gomotif1('sigmotifs/GO/motif5', 'activated by','inhibited by'), gomotif1('sigmotifs/GO/motif8', 'sig','sig by'), gomotif1('sigmotifs/GO/motif9', 'activates','activated by'), gomotif1('sigmotifs/GO/motif10', 'inhibits','inhibited by'), gomotif1('sigmotifs/GO/motif11', 'activates','inhibited by'), gomotif1('sigmotifs/GO/motif12', 'inhibits','activated by'), gomotif1('sigmotifs/GO/motif18', 'sig','sig'), gomotif1('sigmotifs/GO/motif19', 'activates','activates'), gomotif1('sigmotifs/GO/motif20', 'inhibits','inhibits'), gomotif1('sigmotifs/GO/motif21', 'activates','inhibits'). gomotifs2 :- % hiv - human gomotif2('sigmotifs/GO/motif24', 'sig by','sig by'), gomotif2('sigmotifs/GO/motif26', 'activated by','activated by'), gomotif2('sigmotifs/GO/motif27', 'inhibited by','inhibited by'), gomotif2('sigmotifs/GO/motif28', 'activated by','inhibited by'), gomotif2('sigmotifs/GO/motif31', 'sig','sig by'), gomotif2('sigmotifs/GO/motif32', 'activates','activated by'), gomotif2('sigmotifs/GO/motif33', 'inhibits','inhibited by'), gomotif2('sigmotifs/GO/motif34', 'activates','inhibited by'), gomotif2('sigmotifs/GO/motif35', 'inhibits','activated by'), gomotif2('sigmotifs/GO/motif41', 'sig','sig'), gomotif2('sigmotifs/GO/motif42', 'activates','activates'), gomotif2('sigmotifs/GO/motif43', 'inhibits','inhibits'), gomotif2('sigmotifs/GO/motif44', 'activates','inhibits'). gomotifs51 :- % human - hiv - human 1 gomotif51('sigmotifs/GO/motif47', 'sig by','sig by'), gomotif51('sigmotifs/GO/motif49', 'activated by','activated by'), gomotif51('sigmotifs/GO/motif50', 'inhibited by','inhibited by'), gomotif51('sigmotifs/GO/motif51', 'activated by','inhibited by'), gomotif51('sigmotifs/GO/motif54', 'sig','sig by'), gomotif51('sigmotifs/GO/motif55', 'activates','activated by'), gomotif51('sigmotifs/GO/motif56', 'inhibits','inhibited by'), gomotif51('sigmotifs/GO/motif57', 'activates','inhibited by'), gomotif51('sigmotifs/GO/motif58', 'inhibits','activated by'), gomotif51('sigmotifs/GO/motif64', 'sig','sig'), gomotif51('sigmotifs/GO/motif65', 'activates','activates'), gomotif51('sigmotifs/GO/motif66', 'inhibits','inhibits'), gomotif51('sigmotifs/GO/motif67', 'activates','inhibits'). gomotifs61 :- % hiv % / \ % human - human 1 gomotif61('sigmotifs/GO/motif70', 'sig by','sig by'), gomotif61('sigmotifs/GO/motif72', 'activated by','activated by'), gomotif61('sigmotifs/GO/motif73', 'inhibited by','inhibited by'), gomotif61('sigmotifs/GO/motif74', 'activated by','inhibited by'), gomotif61('sigmotifs/GO/motif77', 'sig','sig by'), gomotif61('sigmotifs/GO/motif78', 'activates','activated by'), gomotif61('sigmotifs/GO/motif79', 'inhibits','inhibited by'), gomotif61('sigmotifs/GO/motif80', 'activates','inhibited by'), gomotif61('sigmotifs/GO/motif81', 'inhibits','activated by'), gomotif61('sigmotifs/GO/motif87', 'sig','sig'), gomotif61('sigmotifs/GO/motif88', 'activates','activates'), gomotif61('sigmotifs/GO/motif89', 'inhibits','inhibits'), gomotif61('sigmotifs/GO/motif90', 'activates','inhibits'). gomotifs52 :- % human - hiv - human 2 gomotif52('sigmotifs/GO/motif47', 'sig by','sig by'), gomotif52('sigmotifs/GO/motif49', 'activated by','activated by'), gomotif52('sigmotifs/GO/motif50', 'inhibited by','inhibited by'), gomotif52('sigmotifs/GO/motif51', 'activated by','inhibited by'), gomotif52('sigmotifs/GO/motif54', 'sig','sig by'), gomotif52('sigmotifs/GO/motif55', 'activates','activated by'), gomotif52('sigmotifs/GO/motif56', 'inhibits','inhibited by'), gomotif52('sigmotifs/GO/motif57', 'activates','inhibited by'), gomotif52('sigmotifs/GO/motif58', 'inhibits','activated by'), gomotif52('sigmotifs/GO/motif64', 'sig','sig'), gomotif52('sigmotifs/GO/motif65', 'activates','activates'), gomotif52('sigmotifs/GO/motif66', 'inhibits','inhibits'), gomotif52('sigmotifs/GO/motif67', 'activates','inhibits'). gomotifs62 :- % hiv % / \ % human - human 2 gomotif62('sigmotifs/GO/motif70', 'sig by','sig by'), gomotif62('sigmotifs/GO/motif72', 'activated by','activated by'), gomotif62('sigmotifs/GO/motif73', 'inhibited by','inhibited by'), gomotif62('sigmotifs/GO/motif74', 'activated by','inhibited by'), gomotif62('sigmotifs/GO/motif77', 'sig','sig by'), gomotif62('sigmotifs/GO/motif78', 'activates','activated by'), gomotif62('sigmotifs/GO/motif79', 'inhibits','inhibited by'), gomotif62('sigmotifs/GO/motif80', 'activates','inhibited by'), gomotif62('sigmotifs/GO/motif81', 'inhibits','activated by'), gomotif62('sigmotifs/GO/motif87', 'sig','sig'), gomotif62('sigmotifs/GO/motif88', 'activates','activates'), gomotif62('sigmotifs/GO/motif89', 'inhibits','inhibits'), gomotif62('sigmotifs/GO/motif90', 'activates','inhibits'). % find all occurences of motif1 realmotif1(File, I1, I2) :- findall((N1:N2:N3), motif1(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N), writeList(File,L). % find all occurences of motif2 realmotif2(File, I1, I2) :- findall((N1:N2), motif2(N1,N2,I1,I2),L), length(L,N), writeElement(File,N), writeList(File,L). % find all occurences of motif3 realmotif3(File, I1, I2, I3, I4) :- findall((N1:N2:N3:N4), motif3(N1,N2,N3,N4,I1,I2,I3,I4),L), length(L,N), writeElement(File,N), writeList(File,L). % find all occurences of motif5 realmotif5(File, I1, I2) :- findall((N1:N2:N3), motif5(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N), writeList(File,L). % find all occurences of motif6 realmotif6(File, I1, I2) :- findall((N1:N2:N3), motif6(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N), writeList(File,L). % find all 2 and 3 node motifs realmotifs :- % hiv - human - hiv realmotif1('sigmotifs/motif1', 'sig by','sig by'), realmotif1('sigmotifs/motif3', 'activated by','activated by'), realmotif1('sigmotifs/motif4', 'inhibited by','inhibited by'), realmotif1('sigmotifs/motif5', 'activated by','inhibited by'), realmotif1('sigmotifs/motif8', 'sig','sig by'), realmotif1('sigmotifs/motif9', 'activates','activated by'), realmotif1('sigmotifs/motif10', 'inhibits','inhibited by'), realmotif1('sigmotifs/motif11', 'activates','inhibited by'), realmotif1('sigmotifs/motif12', 'inhibits','activated by'), realmotif1('sigmotifs/motif18', 'sig','sig'), realmotif1('sigmotifs/motif19', 'activates','activates'), realmotif1('sigmotifs/motif20', 'inhibits','inhibits'), realmotif1('sigmotifs/motif21', 'activates','inhibits'), % hiv - human realmotif2('sigmotifs/motif24', 'sig by','sig by'), realmotif2('sigmotifs/motif26', 'activated by','activated by'), realmotif2('sigmotifs/motif27', 'inhibited by','inhibited by'), realmotif2('sigmotifs/motif28', 'activated by','inhibited by'), realmotif2('sigmotifs/motif31', 'sig','sig by'), realmotif2('sigmotifs/motif32', 'activates','activated by'), realmotif2('sigmotifs/motif33', 'inhibits','inhibited by'), realmotif2('sigmotifs/motif34', 'activates','inhibited by'), realmotif2('sigmotifs/motif35', 'inhibits','activated by'), realmotif2('sigmotifs/motif41', 'sig','sig'), realmotif2('sigmotifs/motif42', 'activates','activates'), realmotif2('sigmotifs/motif43', 'inhibits','inhibits'), realmotif2('sigmotifs/motif44', 'activates','inhibits'), % human - hiv - human realmotif5('sigmotifs/motif47', 'sig by','sig by'), realmotif5('sigmotifs/motif49', 'activated by','activated by'), realmotif5('sigmotifs/motif50', 'inhibited by','inhibited by'), realmotif5('sigmotifs/motif51', 'activated by','inhibited by'), realmotif5('sigmotifs/motif54', 'sig','sig by'), realmotif5('sigmotifs/motif55', 'activates','activated by'), realmotif5('sigmotifs/motif56', 'inhibits','inhibited by'), realmotif5('sigmotifs/motif57', 'activates','inhibited by'), realmotif5('sigmotifs/motif58', 'inhibits','activated by'), realmotif5('sigmotifs/motif64', 'sig','sig'), realmotif5('sigmotifs/motif65', 'activates','activates'), realmotif5('sigmotifs/motif66', 'inhibits','inhibits'), realmotif5('sigmotifs/motif67', 'activates','inhibits'), % hiv % / \ % human - human realmotif6('sigmotifs/motif70', 'sig by','sig by'), realmotif6('sigmotifs/motif72', 'activated by','activated by'), realmotif6('sigmotifs/motif73', 'inhibited by','inhibited by'), realmotif6('sigmotifs/motif74', 'activated by','inhibited by'), realmotif6('sigmotifs/motif77', 'sig','sig by'), realmotif6('sigmotifs/motif78', 'activates','activated by'), realmotif6('sigmotifs/motif79', 'inhibits','inhibited by'), realmotif6('sigmotifs/motif80', 'activates','inhibited by'), realmotif6('sigmotifs/motif81', 'inhibits','activated by'), realmotif6('sigmotifs/motif87', 'sig','sig'), realmotif6('sigmotifs/motif88', 'activates','activates'), realmotif6('sigmotifs/motif89', 'inhibits','inhibits'), realmotif6('sigmotifs/motif90', 'activates','inhibits'). % countmotifs2: count all occurences of the motifs countmotifs2 :- % hiv - human - hiv countmotif1('sigmotifs/randmotif1', 'sig by','sig by'), countmotif1('sigmotifs/randmotif3', 'activated by','activated by'), countmotif1('sigmotifs/randmotif4', 'inhibited by','inhibited by'), countmotif1('sigmotifs/randmotif5', 'activated by','inhibited by'), countmotif1('sigmotifs/randmotif8', 'sig','sig by'), countmotif1('sigmotifs/randmotif9', 'activates','activated by'), countmotif1('sigmotifs/randmotif10', 'inhibits','inhibited by'), countmotif1('sigmotifs/randmotif11', 'activates','inhibited by'), countmotif1('sigmotifs/randmotif12', 'inhibits','activated by'), countmotif1('sigmotifs/randmotif18', 'sig','sig'), countmotif1('sigmotifs/randmotif19', 'activates','activates'), countmotif1('sigmotifs/randmotif20', 'inhibits','inhibits'), countmotif1('sigmotifs/randmotif21', 'activates','inhibits'), % hiv - human countmotif2('sigmotifs/randmotif24', 'sig by','sig by'), countmotif2('sigmotifs/randmotif26', 'activated by','activated by'), countmotif2('sigmotifs/randmotif27', 'inhibited by','inhibited by'), countmotif2('sigmotifs/randmotif28', 'activated by','inhibited by'), countmotif2('sigmotifs/randmotif31', 'sig','sig by'), countmotif2('sigmotifs/randmotif32', 'activates','activated by'), countmotif2('sigmotifs/randmotif33', 'inhibits','inhibited by'), countmotif2('sigmotifs/randmotif34', 'activates','inhibited by'), countmotif2('sigmotifs/randmotif35', 'inhibits','activated by'), countmotif2('sigmotifs/randmotif41', 'sig','sig'), countmotif2('sigmotifs/randmotif42', 'activates','activates'), countmotif2('sigmotifs/randmotif43', 'inhibits','inhibits'), countmotif2('sigmotifs/randmotif44', 'activates','inhibits'), % human - hiv - human countmotif5('sigmotifs/randmotif47', 'sig by','sig by'), countmotif5('sigmotifs/randmotif49', 'activated by','activated by'), countmotif5('sigmotifs/randmotif50', 'inhibited by','inhibited by'), countmotif5('sigmotifs/randmotif51', 'activated by','inhibited by'), countmotif5('sigmotifs/randmotif54', 'sig','sig by'), countmotif5('sigmotifs/randmotif55', 'activates','activated by'), countmotif5('sigmotifs/randmotif56', 'inhibits','inhibited by'), countmotif5('sigmotifs/randmotif57', 'activates','inhibited by'), countmotif5('sigmotifs/randmotif58', 'inhibits','activated by'), countmotif5('sigmotifs/randmotif64', 'sig','sig'), countmotif5('sigmotifs/randmotif65', 'activates','activates'), countmotif5('sigmotifs/randmotif66', 'inhibits','inhibits'), countmotif5('sigmotifs/randmotif67', 'activates','inhibits'), % hiv % / \ % human - human countmotif6('sigmotifs/randmotif70', 'sig by','sig by'), countmotif6('sigmotifs/randmotif72', 'activated by','activated by'), countmotif6('sigmotifs/randmotif73', 'inhibited by','inhibited by'), countmotif6('sigmotifs/randmotif74', 'activated by','inhibited by'), countmotif6('sigmotifs/randmotif77', 'sig','sig by'), countmotif6('sigmotifs/randmotif78', 'activates','activated by'), countmotif6('sigmotifs/randmotif79', 'inhibits','inhibited by'), countmotif6('sigmotifs/randmotif80', 'activates','inhibited by'), countmotif6('sigmotifs/randmotif81', 'inhibits','activated by'), countmotif6('sigmotifs/randmotif87', 'sig','sig'), countmotif6('sigmotifs/randmotif88', 'activates','activates'), countmotif6('sigmotifs/randmotif89', 'inhibits','inhibits'), countmotif6('sigmotifs/randmotif90', 'activates','inhibits'). % countmotif1: count all occurences of motif1 countmotif1(File,I1,I2) :- findall((N1,N2,N3), motif1(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N). % countmotif3: count all occurences of motif3 countmotif3(File,I1,I2,I3,I4) :- findall((N1,N2,N3,N4), motif3(N1,N2,N3,N4,I1,I2,I3,I4),L), length(L,N), writeElement(File,N). % countmotif2: count all occurences of motif2 countmotif2(File, I1 ,I2) :- findall((N1,N2), motif2(N1,N2,I1,I2),L), length(L,N), writeElement(File,N). % countmotif5: count all occurences of motif5 countmotif5(File, I1, I2) :- findall((N1:N2:N3), motif5(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N). % countmotif6: count all occurences of motif6 countmotif6(File, I1, I2) :- findall((N1:N2:N3), motif6(N1,N2,N3,I1,I2),L), length(L,N), writeElement(File,N). % go: initialize network, find motifs in real network and count motifs in randomized networks go :- initnetwork, realmotifs, countmotifs(1000). % countmotifs: randomize network and count motifs countmotifs(0) :- !. countmotifs(N) :- randomize3(1000), !, countmotifs2, N2 is N-1, countmotifs(N2). % simplename: use simplified name for certain HIV proteins simplename('Envelope surface glycoprotein gp120', 'gp120') :- !. simplename('Env, gp160', 'gp160') :- !. simplename('gp41, Envelope Transmembrane Protein', 'gp41') :- !. simplename('reverse transcriptase', 'RT') :- !. simplename(N, N). % is_smaller: compare two strings is_smaller(S1, S2) :- name(S1, L1), name(S2, L2), is_smaller2(L1, L2). is_smaller2([], [_|_]). is_smaller2([H1|_], [H2|_]) :- H1 < H2, !. is_smaller2([H|T1], [H|T2]) :- is_smaller2(T1, T2).