From 7f522661d7da349da14404aa7f586e06fea79db2 Mon Sep 17 00:00:00 2001 From: logicmoo Date: Tue, 10 Dec 2024 05:40:16 -0800 Subject: [PATCH] git checkout cf1751605efe30b166b0442c0ab1e369db2be7ef libraries/loaders/genome/flybase_learn.pl --- libraries/loaders/genome/flybase_learn.pl | 541 +--------------------- 1 file changed, 9 insertions(+), 532 deletions(-) diff --git a/libraries/loaders/genome/flybase_learn.pl b/libraries/loaders/genome/flybase_learn.pl index 6373ab7874..8445eeff8f 100644 --- a/libraries/loaders/genome/flybase_learn.pl +++ b/libraries/loaders/genome/flybase_learn.pl @@ -62,7 +62,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The multifile directive allows predicates to be defined across multiple files. - :- multifile(table_n_type/3), multifile(load_state/2), @@ -80,384 +79,6 @@ % %FBbt_00051628 -concept_type(Arg,Type):- - fb_arg(Arg), - fb_arg_table_n(Arg,Fn,N), - table_n_type(Fn,N,Type). - -good_concept(E1):- var(E1),!,table_columns(F1,P1),nth1(N1,P1,E2),(E1=E2;E1=nth(N1,F1)). -good_concept(E1):- symbol(E1),!, is_good_symbol_name(E1). -good_concept(E1):- number(E1),!, E1>300. -good_concept(listOf(E1,_)):- good_concept(E1),symbol(E1). -good_concept(listOf(E1)):- good_concept(E1),symbol(E1). - -%:- abolish(maybe_corisponds/2). -:- dynamic(maybe_corisponds/2). - -is_good_symbol_name(E1):- symbol(E1), symbol_length(E1,L),L>=2, \+ symbol_number(E1,_). - -fb_pred_g(F,A):-fb_pred_nr(F,A), \+ skipped_anotations(F), A>0, A<20. - -mine_corisponds(Concept1,Corispondance):- - fb_arg_table_n(Concept1,Fn1,Nth1),is_good_symbol_name(Concept1), - fb_arg_table_n(Concept1,Fn2,Nth2), - (Fn1+Nth1)@>(Fn2+Nth2), - tables_can_join(Fn1,Fn2), - once((table_colnum_type(Fn1,Nth1,Type1),nonvar(Type1), - table_colnum_type(Fn2,Nth2,Type2),nonvar(Type2))), - (maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/)) - = Corispondance). - -mine_overlaps:- - retractall(maybe_corisponds(_,_)), - time(once(mine_overlaps1)), - skip(mine_overlaps2). - -fbel:- ensure_loaded('flybase.metta.qlf'). -mine_overlaps1:- - for_all(mine_corisponds(Concept1,How), assert_progress(mine_overlaps1(Concept1),How)). - -mine_overlaps2_slow:- - % for_all(mine_typelevel_overlaps,true), - for_all(mine_symbolspace_overlaps,true). - - - - -mine_typelevel_overlaps:- - for_all(mine_typelevel_overlaps(Concept1,SC1,SC2), - assert_progress(mine_typelevel_overlaps(Concept1),maybe_corisponds(SC1,SC2))). - -tables_can_join(Fn1,Fn2):- Fn1@>Fn2, can_join_using(Fn1),can_join_using(Fn2). - -can_join_using(V):- var(V),!. -can_join_using(fbgn_exons2affy1_overlaps):- !, fail. -can_join_using(fbgn_exons2affy2_overlaps):- !, fail. -can_join_using(_). - -fb_data_template(T1,Data):- - fb_pred_g(T1,Arity), Arity>1,Arity<20,functor(Data,T1,Arity), - current_predicate(T1/Arity). -fb_data(T1,Data):- fb_data_template(T1,Data),call(Data). - -:- multifile(fb_arg_table_n/3). -fb_arg_table_n(Arg,Fn,N):- fb_data(Fn,Data),arg(N,Data,Arg). - -querymaker2(CrossType,Inst,[Type1,V1],[Type2,V2],Query):- - xref_class(CrossType), - table_colnum_type(T1,CN1,CrossType), - table_colnum_type(T2,CN2,CrossType), - T1\==T2, - fb_data_template(T1,Data1), - fb_data_template(T2,Data2), - arg(CN1,Data1,Inst),arg(CN2,Data2,Inst), - once((Data1,Data2,is_good_symbol_name(Inst), - - table_colnum_type(T1,Nth1,Type1),Type1\==CrossType, - table_colnum_type(T2,Nth2,Type2),Type2\==CrossType,Type1\==Type2, - arg(Nth1,Data1,V1), - arg(Nth2,Data2,V2), CN1\==Nth1,CN2\==Nth2)), - sort([Type1-V1,CrossType-Inst,Type2-V2],Sorted), - reverse(Sorted,SortedR), - maplist(arg(1),SortedR,Sorted1), - maplist(arg(2),SortedR,Sorted2), - - symbolic_list_concat(Sorted1,'-',QPD), - into_hyphens(QPD,QP), - - Self = '&self', - Query = - [match,Self, - [(','), Data1,Data2], - [QP| Sorted2]], - CQuery = - [match,Self, - [(','), _CData1,_CData2], - [QP,CInst, CV1, CV2 ]], - copy_term(Query,CQuery), - atom_concat(Type2,'_2',Type22), - CV1 = '$VAR'(Type1), CV2 = '$VAR'(Type22), CInst = '$VAR'(CrossType), - numbervars(CQuery,0,_,[]), - nl, - format('~n~n;;; ~w~n~n',[QP]), - write_exec(CQuery),nl,nl, - \+ \+ ((once((Data1,Data2)),write_src(Data1), - if_t((Data1\==Data2),(nl, write_src(Data2))))), - nl,nl. - - -querymaker:- - forall(querymaker(CrossType,Inst,[Type1,V1],[Type2,V2],Query), - write_src(querymaker(CrossType,Inst,[Type1,V1],[Type2,V2],Query))). -querymaker(CrossType,Inst,[Type1,V1],[Type2,V2],Query):- - xref_class(CrossType), - fb_data_template(T1,Data1), - fb_data_template(T2,Data2), - T1\==T2, - table_colnum_type(T1,CN1,CrossType), - table_colnum_type(T2,CN2,CrossType), - table_colnum_type(T1,Nth1,Type1),Type1\==CrossType, - table_colnum_type(T2,Nth2,Type2),Type2\==CrossType,Type1\==Type2, - arg(Nth1,Data1,V1),arg(CN1,Data1,Inst), - arg(Nth2,Data2,V2),arg(CN2,Data2,Inst), - sort([Type1-V1,CrossType-Inst,Type2-V2],Sorted), - reverse(Sorted,SortedR), - maplist(arg(1),SortedR,Sorted1), - maplist(arg(2),SortedR,Sorted2), - symbolic_list_concat(Sorted1,'-',QPD), - into_hyphens(QPD,QP), - - Self = '&self', - Query = - [match,Self, - [(','), Data1,Data2], - [QP|Sorted2]], - CQuery = - [match,Self, - [(','), _CData1,_CData2], - [QP,CInst, CV1, CV2 ]], - copy_term(Query,CQuery), - atom_concat(Type2,'_2',Type22), - CV1 = '$VAR'(Type1), CV2 = '$VAR'(Type22), CInst = '$VAR'(CrossType), - numbervars(CQuery,0,_,[]), - nl, - format('~n~n;;; ~w~n~n',[QP]), - write_exec(CQuery),nl,nl, - \+ \+ ((once((Data1,Data2, Inst\=="")),write_src(Data1), - if_t((Data1\==Data2),(nl, write_src(Data2))))), - nl,nl. - -querymaker3(CrossType,Inst,[Type1,V1],[Type2,V2],Query):- - - - call_nth(fb_data(T1,Data1),3), arg(CN1,Data1,Inst), is_good_symbol_name(Inst), - fb_data_template(T2,Data2),T1\==T2, - arg(CN2,Data2,Inst), - once(Data2), - arg(Nth1,Data1,V1), Nth1\==CN1, - arg(Nth2,Data2,V2), Nth2\==CN2, - table_colnum_type(T1,CN1,CrossType), - table_colnum_type(T1,Nth1,Type1),Type1\==CrossType, - table_colnum_type(T2,Nth2,Type2),Type2\==CrossType,Type1\==Type2, - sort([Type1,CrossType,Type2],Sorted), - reverse(Sorted,SortedR), - symbolic_list_concat(SortedR,'-',QPD), - into_hyphens(QPD,QP), - - Self = '&self', - Query = - [match,Self, - [(','), Data1,Data2], - [QP,Inst, V1, V2 ]], - - \+ \+ - ((user:once((Data1,Data2)), - - CQuery = - [match,Self, - [(','), _CData1,_CData2], - [QP,CInst, CV1, CV2 ]], - copy_term(Query,CQuery), - atom_concat(Type2,'_2',Type22), - CV1 = '$VAR'(Type1), CV2 = '$VAR'(Type22), CInst = '$VAR'(CrossType), - numbervars(CQuery,0,_,[]), - nl, - format('~n~n;;; ~w~n~n',[QP]), - write_exec(CQuery),nl,nl, - ((write_src(Data1), - if_t((Data1\==Data2),(nl, write_src(Data2))))), - nl,nl)). - -interesting_inst(II):- \+ var(II), \+ number(II), II\=='',II\=="". - -same_values(Inst,T1,K1,CN1,T2,K2,CN2):- - fb_pred_g(T1,Arity1),Arity1>1,Arity1<10, - fb_pred_g(T2,Arity2),Arity2>1,Arity2<10, - functor(Data1,T1,Arity1), - functor(Data2,T2,Arity2), - arg(CN1,Data1,Inst), - arg(CN2,Data2,Inst), - ((T1,CN1)\==(T2,CN2)), - call_nth((Data1,Data2),Nth), - (Nth=2->!;true), - ignore(table_colnum_type(T1,CN1,K1)), - ignore(table_colnum_type(T2,CN2,K2)). - -xref_class(CrossType):- no_repeats(CrossType,rep_xref_class(CrossType)). -fb_class(T):- no_repeats(T,table_colnum_type(_,_,T)). - -fb_inst_class(I,IT):- no_repeats(IIT,(fb_data(T,Data),arg(Nth,Data,I),table_colnum_type(T,Nth,IT),(IIT=I+IT))). -rep_xref_class(CrossType):- table_colnum_type(T1,_,CrossType), table_colnum_type(T2,_,CrossType),T1\==T2. - -mine_typelevel_overlaps(Concept1,'ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/)):- - - %fail, % Skip over simple type named things - - Type1=Concept1,Type2=Concept1, - table_columns(Fn1,Atom1), table_columns(Fn2,Atom2), - fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2), - Fn1@>Fn2, nth1(Nth1,Atom1,Concept1), - good_concept(Concept1), - once((nth1(Nth2,Atom2,Concept1),length(Atom1,Arity1),length(Atom2,Arity2))). - -mine_symbolspace_overlaps:- - fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2), - once((functor(Atom1,Fn1,Arity1),functor(Atom2,Fn2,Arity2), - tables_can_join(Fn1,Fn2), - call(Atom1), arg(Nth1,Atom1,Concept1),good_concept(Concept1), arg(Nth2,Atom2,Concept1),call(Atom2))), - once(( - table_colnum_type(Fn1,Nth1,Type1),nonvar(Type1), - table_colnum_type(Fn2,Nth2,Type2),nonvar(Type1))), - assert_progress(Concept1,maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/))). - -mine_unif_overlap:- - forall((fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2), - once((functor(Atom1,Fn1,Arity1),functor(Atom2,Fn2,Arity2), - arg(Nth1,Atom1,Concept1), arg(Nth2,Atom2,Concept1), - call(Atom1),call(Atom2), - interesting_to_unify(Concept1)))), - - assert_progress(Concept1,maybe_corisponds('ConceptMapFn'(Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Nth2,Fn2/*Arity2*/)))). - -interesting_to_unify(Concept1):- string(Concept1),!,symbol_length(Concept1,L),L>3. -interesting_to_unify(Concept1):- good_concept(Concept1). -interesting_to_unify(Number):- number(Number),Number>1000. - - -fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2):- !, - fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2), - tables_can_join(Fn1,Fn2), - between(1,Arity1,Nth1),Nth1<20,between(1,Arity2,Nth2),Nth2<20, - (Fn1==Fn2-> (Nth1>Nth2); true). - -fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2):- - fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2),Fn1@>Fn2, - mine_typelevel_overlaps(_,'ConceptMapFn'(_Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(_Type2,Nth2,Fn2/*Arity2*/)). - -table_colnum_type(Fn,Nth,Type):- table_n_type(Fn,Nth,TypeC,TypeB),(nonvar(TypeB)->Type=TypeB;Type=TypeC). - -synth_conj(QV,(Atom1),(Atom2)):- - maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1),'ConceptMapFn'(Type2,Nth2,Fn2)), - make_symbol(Fn1,Nth1,Atom1,Arg1), - make_symbol(Fn2,Nth2,Atom2,Arg2), - Fn1\=@=Fn2, - skip(Type1),skip(Type2), - Arg1=Arg2,QV=Arg1. - -synth_query(Len,Query):- synth_query(_,Len,Query). - -synth_query(_,1,[Atom]):- !, make_symbol(Atom). -synth_query(QV,N,[Q1,Q2|Query]):- - M is N -1, - synth_conj(QV,Q1,Q2), - (M>1 -> dif(QV,QV2) ; true), - synth_query(QV2,M,[Q2|Query]), - all_dif_functors([Q1,Q2|Query]). - -all_dif_functors(List):- \+ (select(Q1,List,Rest),member(Q2,Rest),functor(Q1,F1,_),functor(Q2,F2,_), F1==F2, \+ (ok_if_dupped(F1))). - -make_symbol(Atom):- fb_pred_g(F,A),functor(Atom,F,A). -make_symbol(Fn,Nth,Atom,Arg):- fb_pred_g(Fn,Arity),functor(Atom,Fn,Arity),arg(Nth,Atom,Arg). - -ok_if_dupped(best_gene_summary). - -try_overlaps:- try_overlaps(5). - -try_overlaps(N):- - synth_query(N,Query), - \+ \+ (call_match(Query), - pp_fb(grounded=Query), - ignore(maybe_english(Query))),nl,nl, - AQ = [','|Query], - pp_fb('!'(match('&flybase',AQ,AQ))),nl,nl,nl. - -no_english(fbrf_pmid_pmcid_doi,_). -no_english(physical_interactions_mitab,8). - -maybe_english(Query):- - extract_concepts(Query,Concepts),!, - ignore((maybe_english(Query,Concepts))),!. - -maybe_english(_Query,Concepts):- select(C,Concepts,Rest),is_englishy(C),member(C2,Rest),is_englishy(C2),!, pp_fb(english=[C,C2]). -maybe_english(_Query,Concepts):- pp_fb(concepts=Concepts), maplist(some_english,Concepts). - -is_englishy(C):- \+ symbol(C), \+ string(C), !, fail. -is_englishy(C):- split_string(C, ". ", " ", [_,_,_|_]). -is_englishy(C):- symbol_contains(C,". "). - -some_english(Term):- - ignore((fb_arg_table_n(C,Fn1,Nth1), \+ no_english(Fn1,Nth1),is_englishy(C), - make_symbol(Fn1,Nth1,Atom,English), - arg(Nth2,Atom,Term),Nth2\==Nth1, - call(Atom),English\=='',!, - pp_fb(Term=English))). - -extract_concepts(Query,Concepts):- - findall(C,(sub_term(C,Query),symbolic(C),good_concept(C)),L), - predsort(longest_first,L,Concepts). - -longest_first(R,A,B):- into_len(A,L1),into_len(B,L2),compare(R,L2,L1). -into_len(A,0):- var(A),!. -into_len(A,L):- \+ string(A), !, sformat(S,"~w",[A]),into_len(S,L). -into_len(A,0+A):- symbol_contains(A," "). -into_len(A,L+A):- symbol_length(A,L1), (L1 == 11 -> L = 0 ; L is - L1). - -assert_progress(Concept,Atom):- Atom=..[OP,A1,A2], A1@>A2,!,AtomSwp=..[OP,A2,A1],!,assert_progress(Concept,AtomSwp). -assert_progress(Concept,Atom):- call(Atom),!,pp_fb(already(Concept)=Atom). -assert_progress(Concept,Atom):- pp_fb(assert_progress(Concept)=Atom),pfcAdd_Now(Atom). - - - -pfb:- - setenv('DISPLAY','10.0.0.122:0.0'), - profile(load_flybase_tiny). - -pfb1:- - setenv('DISPLAY','10.0.0.122:0.0'), - profile(load_flybase(100_000)). - -pfb2:- - setenv('DISPLAY','10.0.0.122:0.0'), - profile(load_flybase(1_000_000)). - -pfb3:- - setenv('DISPLAY','10.0.0.122:0.0'), - profile(load_flybase_full). - - -% Convert a function and its arguments into a compound term -into_datum(Fn, [D|DataL], Data):- - (nb_current(pred_va, 'True') -> Data =.. [Fn,D,DataL]; Data =.. [Fn,D|DataL]). - -% Create a new assertion from old data -make_assertion4(Fn, Cols, NewData, OldData):- fail, - OldData=Cols, - NewData =..[Fn|Cols],!. -make_assertion4(Fn, Cols, NewData, OldData):- - into_datum(Fn, Cols, OldData), - OldData =.. [Fn|Args], - % skip(if_t(var(ArgTypes), must_det_ll_r((once((length(Args,Len),length(ArgTypes,Len),once((table_columns(Fn,ArgTypes);table_columns(F,ArgTypes))))))))), - maybe_fix_args(Fn, Args, NewArgs), - maybe_sample(Fn, NewArgs), - NewData =.. [Fn|NewArgs], !. - -maybe_fix_args( Fn,Args,NewArgs):- do_fix_fast_args( Fn,1,Args,NewArgs),!. -maybe_fix_args( Fn,Args,NewArgs):- should_fix_args, - nb_current(fb_argtypes,ArgTypes), fix_list_args(Fn,ArgTypes,Args,NewArgs),!. -maybe_fix_args(_Fn,Args,Args). - -do_fix_fast_args( Fn,Nth,[A|Args],[New|NewArgs]):- maybe_fix_columns_nth(Fn,Nth,A,New), - Nth2 is Nth+1, !, do_fix_fast_args( Fn,Nth2,Args,NewArgs). -do_fix_fast_args(_,_,A,A). - -maybe_fix_columns_nth(Fn,Nth,A,New):- fix_columns_nth(Fn,Nth), fix_concept(A,New),!. -maybe_fix_columns_nth(_,_,A,A). - - -cleanup_arities:- for_all((fb_pred_nr(F,2),fb_pred_nr(F,N),N>2),retract(fb_pred(F,2))). - - - %! concept_type(+Arg, -Type) is det. % % Determines the type of a given concept (Arg). @@ -1925,22 +1546,8 @@ retract(fb_pred(F, 2)) ). -must_det_ll_r((G1,G2)):- !, once(G1),must_det_ll_r(G2). -must_det_ll_r(G):- call(G). - -% Safely executes the given Goal and prints any exception raised. -% Usage: safe(+Goal, +Info). -safe(Goal, Info) :- - % Try to call Goal. If an exception is raised, unify Exception with the exception. - catch(Goal, Exception, - % If an exception is raised, portray the clause (Info :- Goal) - % along with the exception, then rethrow the exception. - (catch_ignore(portray_clause(exception:Exception:(Info:- Goal))), throw(Exception)) - ). -% Safely executes the given Goal and prints any exception raised. -% Usage: safe(+Goal). -safe(Goal) :- safe(Goal,safe/1). - +:- discontiguous column_names_ext/2. +:- discontiguous primary_column/2. %! must_det_ll_r(+Goal) is det. % @@ -2032,95 +1639,10 @@ % @example Skipped annotations: % ?- skipped_annotations(fbgn_exons2affy1_overlaps). % % Represents that 'fbgn_exons2affy1_overlaps' is excluded. - -%kipped_anotations(fbgn_annotation_ID). -skipped_anotations(transposon_sequence_set). - -gc_now:- set_option_value(gc,true), garbage_collect,garbage_collect_atoms,garbage_collect_clauses. - -extreme_debug(_). - -numbervars_w_singles(P):- term_singletons(P, Vars), - numbervars(Vars,260,_,[attvar(bind),singletons(false)]), - numbervars(P,14,_,[attvar(bind),singletons(true)]). - - - -pp_fb(P):- format("~N "), \+ \+ (numbervars_w_singles(P), pp_fb1(P)),flush_output. -pp_fb1(P):- write_src(P),!,nl. -:- if(current_predicate(pp_ilp/1)). -pp_fb1(P):- pp_as(P),!,format("~N"),pp_ilp(P),!. -:- endif. -pp_fb1(P):- pp_as(P),!. -pp_fb1(P):- print(P),!,nl. -pp_fb1(P):- fbdebug1(P),!,nl. - - -fbgn_exons2affy1_overlaps_each(Gene,At):- - fb_pred_nr(fbgn_exons2affy1_overlaps, Arity), - functor(Pred,fbgn_exons2affy1_overlaps, Arity), - arg(1,Pred,Gene), - call(Pred), - arg(N,Pred,At),N>1. - -fbgn_exons2affy1_overlaps_start_end(Gene,Start,End):- - fbgn_exons2affy1_overlaps_each(Gene,At),into_start_end(At,Start,End). - - -into_start_end(s_e(S,E),S,E):- nonvar(S),!. -into_start_end('..'(S,E),S,E):- nonvar(S),!. -into_start_end(at(S,E),S,E):- nonvar(S),!. -into_start_end(At,S,E):- symbolic_list_concat([SS,EE],'..',At), - into_number_or_symbol(SS,S), into_number_or_symbol(EE,E). -into_start_end(At,S,E):- symbolic_list_concat([SS,EE],'_at_',At), - into_number_or_symbol(SS,S), into_number_or_symbol(EE,E). - - -%into_fb_term(Atom,Term):- compound(Atom),!,Term=Atom. -into_fb_term(Atom,Term):- \+ atom(Atom), \+ string(Atom),!,Term=Atom. -into_fb_term(Atom,'..'(S,E)):- into_start_end(Atom,S,E),!. -into_fb_term(Atom,Term):- into_number_or_symbol(Atom,Term),!. - -fb_member(E,L):- as_list([],L,LL),member(E,LL). - -into_number_or_symbol(Atom,Term):- symbolic_list_concat(List,'|',Atom),List\=[_],!,maplist(into_fb_term,List,Term). -%into_number_or_symbol(Atom,Term):- atom_number(Atom, Term),!,Term= Term. -into_number_or_symbol(Atom,Term):- catch(atom_to_term(Atom,Term,Vars),_,fail),maplist(a2t_assign_var,Vars). -into_number_or_symbol(Atom,Term):- Term=Atom. - -a2t_assign_var(N=V):- N=V. - -fbgn_exons2affy2_overlaps_each(Gene,At):- - fb_pred_nr(fbgn_exons2affy2_overlaps, Arity), - functor(Pred,fbgn_exons2affy2_overlaps, Arity), - arg(1,Pred,Gene), - call(Pred), - arg(N,Pred,At),N>1. - -fbgn_exons2affy2_overlaps_start_end(Gene,Start,End):- - fbgn_exons2affy2_overlaps_each(Gene,At),into_start_end(At,Start,End). - -some_xref_ids(Id):- member(Id,['FBgn0001301']). - -findall_flat_set(Arg,Goal,FlatSet):- - findall(Arg,Goal,List),flatten(List,Flat),list_to_set(Flat,FlatSet),!. - -expand_xref(Id,N,SetOfArgs):- - expand_xref_excpt([[]],Id,N,SetOfArgs). - -expand_xref_excpt(_Xcept,Id,_N,SetOfArgs):- compound(Id),!,SetOfArgs=[]. -expand_xref_excpt(Except,Id,N,SetOfArgs):- var(N),!,between(0,5,N),expand_xref_excpt(Except,Id,N,SetOfArgs). -expand_xref_excpt(Except,Id,N,SetOfArgs):- N=<1,!, - findall_flat_set(SoFar,expand_xref_once_except(Except,Id,N,SoFar),SetOfArgs). -expand_xref_excpt(Except,Id,N,SetOfArgs):- Nm1 is N -1, - expand_xref_once_except(Except,Id,1,SetOfArgs1), - findall_flat_set(EArgs,(member(E,SetOfArgs1),expand_xref_excpt([Id|Except],E,Nm1,EArgs)),SetOfArgs). - -gather_args(Except,F,Pred,Args):- findall_flat_set(Arg,gather_args(Except,F,Pred,Arg),Args). -gather_each_args(Except,F,Pred,Ele):- arg(N,Pred,Arg), \+ member(Arg,Except), - (number(Arg)-> Ele = is_nthOf(Arg,F,N) ; Ele = Arg). - - +skipped_anotations(fbgn_exons2affy1_overlaps). +skipped_anotations(fbgn_exons2affy2_overlaps). +skipped_anotations(gene_rpkm_matrix). +skipped_anotations(dmel_gene_sequence_ontology_annotations). % skipped_anotations(fbgn_annotation_ID). skipped_anotations(transposon_sequence_set). @@ -2612,52 +2134,9 @@ Ele = Arg ). - -expand_xref_once_except(Except,Id,P1):- nonvar(P1), \+ is_list(P1), - forall(between(1,6,N), - expand_xref_once_except_each(Except,Id,N,P1)). - -expand_xref_once_except(Except,Id,Set):- - ((between(1,6,N),expand_xref_once_except_each(Except,Id,N,nop),fail) - ->true;Set=Except). - -expand_xref_once_except_each(Except,Id,N,P1):- - fb_pred_nr(F, Arity), - xgc, - \+ member(argNOf(N,F/Arity),Except), \+ member(F/Arity,Except), - Arity>=N, - expand_xref_once_except_each_fa(Except,F,Arity,Id,N,P1). - - -expand_xref_once_except_each_fa(Except,F,Arity,Id,N,P1):- - functor(Pred,F, Arity), - arg(N,Pred,Id), - call(Pred), - add_to_except(argNOf(N,F/Arity),Except), - % \+ member(Pred,Except), - % add_to_except(Pred,Except), - call(P1,Pred), - xgc. - -xgc:- - garbage_collect, - garbage_collect_atoms, - garbage_collect_clauses, - sleep(0.033). - -add_to_except(Pred,Except):- arg(2,Except,T), nb_setarg(2,Except,[Pred|T]). - -sx1:- xinfo(_Id). - -xinfo(Id):- var(Id),!,some_xref_ids(Id), xinfo(Id). -xinfo(Id):- Id=='',!. -xinfo(Id):- number(Id),!. -xinfo(Id):- expand_xref_once_except([Id],Id,my_write_src_nl). - -my_write_src_nl(X):-!, write_src_nl(X). -my_write_src_nl(X):- - must_det_ll((X=..[F|L], maplist(fast_column,L,LL),!,write_src_nl([F|LL]))). - +% findall_flat_set([Pred|Args], +% (call(Pred), +% (N=0 -> Args = [] ; gather_args([Id|Except],F,Pred,Args))),SetOfArgs). %! expand_xref_once_except(+Except, +Id, +P1) is det. % @@ -2852,7 +2331,6 @@ ) ). - /* xinfo(Id, N):- var(Id),!,some_xref_ids(Id), xinfo(Id,N). @@ -2916,7 +2394,6 @@ % % % Example: Unique value statistics for column 1 of 'allele_genetic_interactions'. % ?- fb_tsv_pred_stats('unique-values', allele_genetic_interactions, [1, 28688, object]). - fb_tsv_pred_stats('num-columns', allele_genetic_interactions, [4]). fb_tsv_pred_stats('duplicated-rows', allele_genetic_interactions, [21]). fb_tsv_pred_stats('total-rows', allele_genetic_interactions, [363452]).