% 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 == 'regulates'|I1 == 'upregulates'|I1 == 'downregulates'), (I2 == 'regulated by'|I2 == 'upregulated by'|I2 == 'downregulated by'), n(N1, 'type', 'hiv',_), n(N2, 'type', 'human',_), n(N3, 'type', 'hiv',_), assert(e(N1, N3, 'indirectly_regulates', 8888888)). % nettodirect: for all hiv-human-hiv assert hiv-hiv nettodirect :- findall(_,todirect,_). % indirectnettocsv: write all 'indirectly_regulates' interactions to file indirectnettocsv(File) :- findall((NN1:NN2), (e(N1,N2,'indirectly_regulates',_),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(regnetwork). % 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('regmotifs/GO/motif1', 'reg by','reg by'), gomotif1('regmotifs/GO/motif2', 'regulated by','regulated by'), gomotif1('regmotifs/GO/motif3', 'upregulated by','upregulated by'), gomotif1('regmotifs/GO/motif4', 'downregulated by','downregulated by'), gomotif1('regmotifs/GO/motif5', 'upregulated by','downregulated by'), gomotif1('regmotifs/GO/motif6', 'regulated by','upregulated by'), gomotif1('regmotifs/GO/motif7', 'regulated by','downregulated by'), gomotif1('regmotifs/GO/motif8', 'reg','reg by'), gomotif1('regmotifs/GO/motif9', 'upregulates','upregulated by'), gomotif1('regmotifs/GO/motif10', 'downregulates','downregulated by'), gomotif1('regmotifs/GO/motif11', 'upregulates','downregulated by'), gomotif1('regmotifs/GO/motif12', 'downregulates','upregulated by'), gomotif1('regmotifs/GO/motif13', 'regulates','regulated by'), gomotif1('regmotifs/GO/motif14', 'regulates','upregulated by'), gomotif1('regmotifs/GO/motif15', 'regulates','downregulated by'), gomotif1('regmotifs/GO/motif16', 'upregulates','regulated by'), gomotif1('regmotifs/GO/motif17', 'downregulates','regulated by'), gomotif1('regmotifs/GO/motif18', 'reg','reg'), gomotif1('regmotifs/GO/motif19', 'upregulates','upregulates'), gomotif1('regmotifs/GO/motif20', 'downregulates','downregulates'), gomotif1('regmotifs/GO/motif21', 'upregulates','downregulates'), gomotif1('regmotifs/GO/motif22', 'regulates','upregulates'), gomotif1('regmotifs/GO/motif23', 'regulates','downregulates'). gomotifs2 :- % hiv - human gomotif2('regmotifs/GO/motif24', 'reg by','reg by'), gomotif2('regmotifs/GO/motif25', 'regulated by','regulated by'), gomotif2('regmotifs/GO/motif26', 'upregulated by','upregulated by'), gomotif2('regmotifs/GO/motif27', 'downregulated by','downregulated by'), gomotif2('regmotifs/GO/motif28', 'upregulated by','downregulated by'), gomotif2('regmotifs/GO/motif29', 'regulated by','upregulated by'), gomotif2('regmotifs/GO/motif30', 'regulated by','downregulated by'), gomotif2('regmotifs/GO/motif31', 'reg','reg by'), gomotif2('regmotifs/GO/motif32', 'upregulates','upregulated by'), gomotif2('regmotifs/GO/motif33', 'downregulates','downregulated by'), gomotif2('regmotifs/GO/motif34', 'upregulates','downregulated by'), gomotif2('regmotifs/GO/motif35', 'downregulates','upregulated by'), gomotif2('regmotifs/GO/motif36', 'regulates','regulated by'), gomotif2('regmotifs/GO/motif37', 'regulates','upregulated by'), gomotif2('regmotifs/GO/motif38', 'regulates','downregulated by'), gomotif2('regmotifs/GO/motif39', 'upregulates','regulated by'), gomotif2('regmotifs/GO/motif40', 'downregulates','regulated by'), gomotif2('regmotifs/GO/motif41', 'reg','reg'), gomotif2('regmotifs/GO/motif42', 'upregulates','upregulates'), gomotif2('regmotifs/GO/motif43', 'downregulates','downregulates'), gomotif2('regmotifs/GO/motif44', 'upregulates','downregulates'), gomotif2('regmotifs/GO/motif45', 'regulates','upregulates'), gomotif2('regmotifs/GO/motif46', 'regulates','downregulates'). gomotifs51 :- % human - hiv - human 1 gomotif51('regmotifs/GO/motif47', 'reg by','reg by'), gomotif51('regmotifs/GO/motif48', 'regulated by','regulated by'), gomotif51('regmotifs/GO/motif49', 'upregulated by','upregulated by'), gomotif51('regmotifs/GO/motif50', 'downregulated by','downregulated by'), gomotif51('regmotifs/GO/motif51', 'upregulated by','downregulated by'), gomotif51('regmotifs/GO/motif52', 'regulated by','upregulated by'), gomotif51('regmotifs/GO/motif53', 'regulated by','downregulated by'), gomotif51('regmotifs/GO/motif54', 'reg','reg by'), gomotif51('regmotifs/GO/motif55', 'upregulates','upregulated by'), gomotif51('regmotifs/GO/motif56', 'downregulates','downregulated by'), gomotif51('regmotifs/GO/motif57', 'upregulates','downregulated by'), gomotif51('regmotifs/GO/motif58', 'downregulates','upregulated by'), gomotif51('regmotifs/GO/motif59', 'regulates','regulated by'), gomotif51('regmotifs/GO/motif60', 'regulates','upregulated by'), gomotif51('regmotifs/GO/motif61', 'regulates','downregulated by'), gomotif51('regmotifs/GO/motif62', 'upregulates','regulated by'), gomotif51('regmotifs/GO/motif63', 'downregulates','regulated by'), gomotif51('regmotifs/GO/motif64', 'reg','reg'), gomotif51('regmotifs/GO/motif65', 'upregulates','upregulates'), gomotif51('regmotifs/GO/motif66', 'downregulates','downregulates'), gomotif51('regmotifs/GO/motif67', 'upregulates','downregulates'), gomotif51('regmotifs/GO/motif68', 'regulates','upregulates'), gomotif51('regmotifs/GO/motif69', 'regulates','downregulates'). gomotifs61 :- % hiv % / \ % human - human 1 gomotif61('regmotifs/GO/motif70', 'reg by','reg by'), gomotif61('regmotifs/GO/motif71', 'regulated by','regulated by'), gomotif61('regmotifs/GO/motif72', 'upregulated by','upregulated by'), gomotif61('regmotifs/GO/motif73', 'downregulated by','downregulated by'), gomotif61('regmotifs/GO/motif74', 'upregulated by','downregulated by'), gomotif61('regmotifs/GO/motif75', 'regulated by','upregulated by'), gomotif61('regmotifs/GO/motif76', 'regulated by','downregulated by'), gomotif61('regmotifs/GO/motif77', 'reg','reg by'), gomotif61('regmotifs/GO/motif78', 'upregulates','upregulated by'), gomotif61('regmotifs/GO/motif79', 'downregulates','downregulated by'), gomotif61('regmotifs/GO/motif80', 'upregulates','downregulated by'), gomotif61('regmotifs/GO/motif81', 'downregulates','upregulated by'), gomotif61('regmotifs/GO/motif82', 'regulates','regulated by'), gomotif61('regmotifs/GO/motif83', 'regulates','upregulated by'), gomotif61('regmotifs/GO/motif84', 'regulates','downregulated by'), gomotif61('regmotifs/GO/motif85', 'upregulates','regulated by'), gomotif61('regmotifs/GO/motif86', 'downregulates','regulated by'), gomotif61('regmotifs/GO/motif87', 'reg','reg'), gomotif61('regmotifs/GO/motif88', 'upregulates','upregulates'), gomotif61('regmotifs/GO/motif89', 'downregulates','downregulates'), gomotif61('regmotifs/GO/motif90', 'upregulates','downregulates'), gomotif61('regmotifs/GO/motif91', 'regulates','upregulates'), gomotif61('regmotifs/GO/motif92', 'regulates','downregulates'). gomotifs52 :- % human - hiv - human 2 gomotif52('regmotifs/GO/motif47', 'reg by','reg by'), gomotif52('regmotifs/GO/motif48', 'regulated by','regulated by'), gomotif52('regmotifs/GO/motif49', 'upregulated by','upregulated by'), gomotif52('regmotifs/GO/motif50', 'downregulated by','downregulated by'), gomotif52('regmotifs/GO/motif51', 'upregulated by','downregulated by'), gomotif52('regmotifs/GO/motif52', 'regulated by','upregulated by'), gomotif52('regmotifs/GO/motif53', 'regulated by','downregulated by'), gomotif52('regmotifs/GO/motif54', 'reg','reg by'), gomotif52('regmotifs/GO/motif55', 'upregulates','upregulated by'), gomotif52('regmotifs/GO/motif56', 'downregulates','downregulated by'), gomotif52('regmotifs/GO/motif57', 'upregulates','downregulated by'), gomotif52('regmotifs/GO/motif58', 'downregulates','upregulated by'), gomotif52('regmotifs/GO/motif59', 'regulates','regulated by'), gomotif52('regmotifs/GO/motif60', 'regulates','upregulated by'), gomotif52('regmotifs/GO/motif61', 'regulates','downregulated by'), gomotif52('regmotifs/GO/motif62', 'upregulates','regulated by'), gomotif52('regmotifs/GO/motif63', 'downregulates','regulated by'), gomotif52('regmotifs/GO/motif64', 'reg','reg'), gomotif52('regmotifs/GO/motif65', 'upregulates','upregulates'), gomotif52('regmotifs/GO/motif66', 'downregulates','downregulates'), gomotif52('regmotifs/GO/motif67', 'upregulates','downregulates'), gomotif52('regmotifs/GO/motif68', 'regulates','upregulates'), gomotif52('regmotifs/GO/motif69', 'regulates','downregulates'). gomotifs62 :- % hiv % / \ % human - human 2 gomotif62('regmotifs/GO/motif70', 'reg by','reg by'), gomotif62('regmotifs/GO/motif71', 'regulated by','regulated by'), gomotif62('regmotifs/GO/motif72', 'upregulated by','upregulated by'), gomotif62('regmotifs/GO/motif73', 'downregulated by','downregulated by'), gomotif62('regmotifs/GO/motif74', 'upregulated by','downregulated by'), gomotif62('regmotifs/GO/motif75', 'regulated by','upregulated by'), gomotif62('regmotifs/GO/motif76', 'regulated by','downregulated by'), gomotif62('regmotifs/GO/motif77', 'reg','reg by'), gomotif62('regmotifs/GO/motif78', 'upregulates','upregulated by'), gomotif62('regmotifs/GO/motif79', 'downregulates','downregulated by'), gomotif62('regmotifs/GO/motif80', 'upregulates','downregulated by'), gomotif62('regmotifs/GO/motif81', 'downregulates','upregulated by'), gomotif62('regmotifs/GO/motif82', 'regulates','regulated by'), gomotif62('regmotifs/GO/motif83', 'regulates','upregulated by'), gomotif62('regmotifs/GO/motif84', 'regulates','downregulated by'), gomotif62('regmotifs/GO/motif85', 'upregulates','regulated by'), gomotif62('regmotifs/GO/motif86', 'downregulates','regulated by'), gomotif62('regmotifs/GO/motif87', 'reg','reg'), gomotif62('regmotifs/GO/motif88', 'upregulates','upregulates'), gomotif62('regmotifs/GO/motif89', 'downregulates','downregulates'), gomotif62('regmotifs/GO/motif90', 'upregulates','downregulates'), gomotif62('regmotifs/GO/motif91', 'regulates','upregulates'), gomotif62('regmotifs/GO/motif92', 'regulates','downregulates'). % 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('regmotifs/motif1', 'reg by','reg by'), realmotif1('regmotifs/motif2', 'regulated by','regulated by'), realmotif1('regmotifs/motif3', 'upregulated by','upregulated by'), realmotif1('regmotifs/motif4', 'downregulated by','downregulated by'), realmotif1('regmotifs/motif5', 'upregulated by','downregulated by'), realmotif1('regmotifs/motif6', 'regulated by','upregulated by'), realmotif1('regmotifs/motif7', 'regulated by','downregulated by'), realmotif1('regmotifs/motif8', 'reg','reg by'), realmotif1('regmotifs/motif9', 'upregulates','upregulated by'), realmotif1('regmotifs/motif10', 'downregulates','downregulated by'), realmotif1('regmotifs/motif11', 'upregulates','downregulated by'), realmotif1('regmotifs/motif12', 'downregulates','upregulated by'), realmotif1('regmotifs/motif13', 'regulates','regulated by'), realmotif1('regmotifs/motif14', 'regulates','upregulated by'), realmotif1('regmotifs/motif15', 'regulates','downregulated by'), realmotif1('regmotifs/motif16', 'upregulates','regulated by'), realmotif1('regmotifs/motif17', 'downregulates','regulated by'), realmotif1('regmotifs/motif18', 'reg','reg'), realmotif1('regmotifs/motif19', 'upregulates','upregulates'), realmotif1('regmotifs/motif20', 'downregulates','downregulates'), realmotif1('regmotifs/motif21', 'upregulates','downregulates'), realmotif1('regmotifs/motif22', 'regulates','upregulates'), realmotif1('regmotifs/motif23', 'regulates','downregulates'), % hiv - human realmotif2('regmotifs/motif24', 'reg by','reg by'), realmotif2('regmotifs/motif25', 'regulated by','regulated by'), realmotif2('regmotifs/motif26', 'upregulated by','upregulated by'), realmotif2('regmotifs/motif27', 'downregulated by','downregulated by'), realmotif2('regmotifs/motif28', 'upregulated by','downregulated by'), realmotif2('regmotifs/motif29', 'regulated by','upregulated by'), realmotif2('regmotifs/motif30', 'regulated by','downregulated by'), realmotif2('regmotifs/motif31', 'reg','reg by'), realmotif2('regmotifs/motif32', 'upregulates','upregulated by'), realmotif2('regmotifs/motif33', 'downregulates','downregulated by'), realmotif2('regmotifs/motif34', 'upregulates','downregulated by'), realmotif2('regmotifs/motif35', 'downregulates','upregulated by'), realmotif2('regmotifs/motif36', 'regulates','regulated by'), realmotif2('regmotifs/motif37', 'regulates','upregulated by'), realmotif2('regmotifs/motif38', 'regulates','downregulated by'), realmotif2('regmotifs/motif39', 'upregulates','regulated by'), realmotif2('regmotifs/motif40', 'downregulates','regulated by'), realmotif2('regmotifs/motif41', 'reg','reg'), realmotif2('regmotifs/motif42', 'upregulates','upregulates'), realmotif2('regmotifs/motif43', 'downregulates','downregulates'), realmotif2('regmotifs/motif44', 'upregulates','downregulates'), realmotif2('regmotifs/motif45', 'regulates','upregulates'), realmotif2('regmotifs/motif46', 'regulates','downregulates'), % human - hiv - human realmotif5('regmotifs/motif47', 'reg by','reg by'), realmotif5('regmotifs/motif48', 'regulated by','regulated by'), realmotif5('regmotifs/motif49', 'upregulated by','upregulated by'), realmotif5('regmotifs/motif50', 'downregulated by','downregulated by'), realmotif5('regmotifs/motif51', 'upregulated by','downregulated by'), realmotif5('regmotifs/motif52', 'regulated by','upregulated by'), realmotif5('regmotifs/motif53', 'regulated by','downregulated by'), realmotif5('regmotifs/motif54', 'reg','reg by'), realmotif5('regmotifs/motif55', 'upregulates','upregulated by'), realmotif5('regmotifs/motif56', 'downregulates','downregulated by'), realmotif5('regmotifs/motif57', 'upregulates','downregulated by'), realmotif5('regmotifs/motif58', 'downregulates','upregulated by'), realmotif5('regmotifs/motif59', 'regulates','regulated by'), realmotif5('regmotifs/motif60', 'regulates','upregulated by'), realmotif5('regmotifs/motif61', 'regulates','downregulated by'), realmotif5('regmotifs/motif62', 'upregulates','regulated by'), realmotif5('regmotifs/motif63', 'downregulates','regulated by'), realmotif5('regmotifs/motif64', 'reg','reg'), realmotif5('regmotifs/motif65', 'upregulates','upregulates'), realmotif5('regmotifs/motif66', 'downregulates','downregulates'), realmotif5('regmotifs/motif67', 'upregulates','downregulates'), realmotif5('regmotifs/motif68', 'regulates','upregulates'), realmotif5('regmotifs/motif69', 'regulates','downregulates'), % hiv % / \ % human - human realmotif6('regmotifs/motif70', 'reg by','reg by'), realmotif6('regmotifs/motif71', 'regulated by','regulated by'), realmotif6('regmotifs/motif72', 'upregulated by','upregulated by'), realmotif6('regmotifs/motif73', 'downregulated by','downregulated by'), realmotif6('regmotifs/motif74', 'upregulated by','downregulated by'), realmotif6('regmotifs/motif75', 'regulated by','upregulated by'), realmotif6('regmotifs/motif76', 'regulated by','downregulated by'), realmotif6('regmotifs/motif77', 'reg','reg by'), realmotif6('regmotifs/motif78', 'upregulates','upregulated by'), realmotif6('regmotifs/motif79', 'downregulates','downregulated by'), realmotif6('regmotifs/motif80', 'upregulates','downregulated by'), realmotif6('regmotifs/motif81', 'downregulates','upregulated by'), realmotif6('regmotifs/motif82', 'regulates','regulated by'), realmotif6('regmotifs/motif83', 'regulates','upregulated by'), realmotif6('regmotifs/motif84', 'regulates','downregulated by'), realmotif6('regmotifs/motif85', 'upregulates','regulated by'), realmotif6('regmotifs/motif86', 'downregulates','regulated by'), realmotif6('regmotifs/motif87', 'reg','reg'), realmotif6('regmotifs/motif88', 'upregulates','upregulates'), realmotif6('regmotifs/motif89', 'downregulates','downregulates'), realmotif6('regmotifs/motif90', 'upregulates','downregulates'), realmotif6('regmotifs/motif91', 'regulates','upregulates'), realmotif6('regmotifs/motif92', 'regulates','downregulates'). % countmotifs2: count all occurences of the motifs countmotifs2 :- % hiv - human - hiv countmotif1('regmotifs/randmotif1', 'reg by','reg by'), countmotif1('regmotifs/randmotif2', 'regulated by','regulated by'), countmotif1('regmotifs/randmotif3', 'upregulated by','upregulated by'), countmotif1('regmotifs/randmotif4', 'downregulated by','downregulated by'), countmotif1('regmotifs/randmotif5', 'upregulated by','downregulated by'), countmotif1('regmotifs/randmotif6', 'regulated by','upregulated by'), countmotif1('regmotifs/randmotif7', 'regulated by','downregulated by'), countmotif1('regmotifs/randmotif8', 'reg','reg by'), countmotif1('regmotifs/randmotif9', 'upregulates','upregulated by'), countmotif1('regmotifs/randmotif10', 'downregulates','downregulated by'), countmotif1('regmotifs/randmotif11', 'upregulates','downregulated by'), countmotif1('regmotifs/randmotif12', 'downregulates','upregulated by'), countmotif1('regmotifs/randmotif13', 'regulates','regulated by'), countmotif1('regmotifs/randmotif14', 'regulates','upregulated by'), countmotif1('regmotifs/randmotif15', 'regulates','downregulated by'), countmotif1('regmotifs/randmotif16', 'upregulates','regulated by'), countmotif1('regmotifs/randmotif17', 'downregulates','regulated by'), countmotif1('regmotifs/randmotif18', 'reg','reg'), countmotif1('regmotifs/randmotif19', 'upregulates','upregulates'), countmotif1('regmotifs/randmotif20', 'downregulates','downregulates'), countmotif1('regmotifs/randmotif21', 'upregulates','downregulates'), countmotif1('regmotifs/randmotif22', 'regulates','upregulates'), countmotif1('regmotifs/randmotif23', 'regulates','downregulates'), % hiv - human countmotif2('regmotifs/randmotif24', 'reg by','reg by'), countmotif2('regmotifs/randmotif25', 'regulated by','regulated by'), countmotif2('regmotifs/randmotif26', 'upregulated by','upregulated by'), countmotif2('regmotifs/randmotif27', 'downregulated by','downregulated by'), countmotif2('regmotifs/randmotif28', 'upregulated by','downregulated by'), countmotif2('regmotifs/randmotif29', 'regulated by','upregulated by'), countmotif2('regmotifs/randmotif30', 'regulated by','downregulated by'), countmotif2('regmotifs/randmotif31', 'reg','reg by'), countmotif2('regmotifs/randmotif32', 'upregulates','upregulated by'), countmotif2('regmotifs/randmotif33', 'downregulates','downregulated by'), countmotif2('regmotifs/randmotif34', 'upregulates','downregulated by'), countmotif2('regmotifs/randmotif35', 'downregulates','upregulated by'), countmotif2('regmotifs/randmotif36', 'regulates','regulated by'), countmotif2('regmotifs/randmotif37', 'regulates','upregulated by'), countmotif2('regmotifs/randmotif38', 'regulates','downregulated by'), countmotif2('regmotifs/randmotif39', 'upregulates','regulated by'), countmotif2('regmotifs/randmotif40', 'downregulates','regulated by'), countmotif2('regmotifs/randmotif41', 'reg','reg'), countmotif2('regmotifs/randmotif42', 'upregulates','upregulates'), countmotif2('regmotifs/randmotif43', 'downregulates','downregulates'), countmotif2('regmotifs/randmotif44', 'upregulates','downregulates'), countmotif2('regmotifs/randmotif45', 'regulates','upregulates'), countmotif2('regmotifs/randmotif46', 'regulates','downregulates'), % human - hiv - human countmotif5('regmotifs/randmotif47', 'reg by','reg by'), countmotif5('regmotifs/randmotif48', 'regulated by','regulated by'), countmotif5('regmotifs/randmotif49', 'upregulated by','upregulated by'), countmotif5('regmotifs/randmotif50', 'downregulated by','downregulated by'), countmotif5('regmotifs/randmotif51', 'upregulated by','downregulated by'), countmotif5('regmotifs/randmotif52', 'regulated by','upregulated by'), countmotif5('regmotifs/randmotif53', 'regulated by','downregulated by'), countmotif5('regmotifs/randmotif54', 'reg','reg by'), countmotif5('regmotifs/randmotif55', 'upregulates','upregulated by'), countmotif5('regmotifs/randmotif56', 'downregulates','downregulated by'), countmotif5('regmotifs/randmotif57', 'upregulates','downregulated by'), countmotif5('regmotifs/randmotif58', 'downregulates','upregulated by'), countmotif5('regmotifs/randmotif59', 'regulates','regulated by'), countmotif5('regmotifs/randmotif60', 'regulates','upregulated by'), countmotif5('regmotifs/randmotif61', 'regulates','downregulated by'), countmotif5('regmotifs/randmotif62', 'upregulates','regulated by'), countmotif5('regmotifs/randmotif63', 'downregulates','regulated by'), countmotif5('regmotifs/randmotif64', 'reg','reg'), countmotif5('regmotifs/randmotif65', 'upregulates','upregulates'), countmotif5('regmotifs/randmotif66', 'downregulates','downregulates'), countmotif5('regmotifs/randmotif67', 'upregulates','downregulates'), countmotif5('regmotifs/randmotif68', 'regulates','upregulates'), countmotif5('regmotifs/randmotif69', 'regulates','downregulates'), % hiv % / \ % human - human countmotif6('regmotifs/randmotif70', 'reg by','reg by'), countmotif6('regmotifs/randmotif71', 'regulated by','regulated by'), countmotif6('regmotifs/randmotif72', 'upregulated by','upregulated by'), countmotif6('regmotifs/randmotif73', 'downregulated by','downregulated by'), countmotif6('regmotifs/randmotif74', 'upregulated by','downregulated by'), countmotif6('regmotifs/randmotif75', 'regulated by','upregulated by'), countmotif6('regmotifs/randmotif76', 'regulated by','downregulated by'), countmotif6('regmotifs/randmotif77', 'reg','reg by'), countmotif6('regmotifs/randmotif78', 'upregulates','upregulated by'), countmotif6('regmotifs/randmotif79', 'downregulates','downregulated by'), countmotif6('regmotifs/randmotif80', 'upregulates','downregulated by'), countmotif6('regmotifs/randmotif81', 'downregulates','upregulated by'), countmotif6('regmotifs/randmotif82', 'regulates','regulated by'), countmotif6('regmotifs/randmotif83', 'regulates','upregulated by'), countmotif6('regmotifs/randmotif84', 'regulates','downregulated by'), countmotif6('regmotifs/randmotif85', 'upregulates','regulated by'), countmotif6('regmotifs/randmotif86', 'downregulates','regulated by'), countmotif6('regmotifs/randmotif87', 'reg','reg'), countmotif6('regmotifs/randmotif88', 'upregulates','upregulates'), countmotif6('regmotifs/randmotif89', 'downregulates','downregulates'), countmotif6('regmotifs/randmotif90', 'upregulates','downregulates'), countmotif6('regmotifs/randmotif91', 'regulates','upregulates'), countmotif6('regmotifs/randmotif92', 'regulates','downregulates'). % 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(10000), !, 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).