Changeset 27335 in project
 Timestamp:
 08/30/12 10:54:39 (9 years ago)
 Location:
 release/4/nemo/trunk
 Files:

 1 deleted
 1 edited
Legend:
 Unmodified
 Added
 Removed

release/4/nemo/trunk/nemo.scm
r27093 r27335 98 98 (value (required FORMAT) 99 99 (transformer ,string>symbol))) 100 101 (surfacexml 102 "write surface XML translation of input to file (default: <modelname>.xml)" 103 (value (optional FILENAME) 104 )) 100 105 101 106 (xml … … 927 932 928 933 934 (define (entry>surfacexml x) 935 936 (match x 937 (('nemomodel name decls) 938 (map entry>surfacexml decls)) 939 940 (('output . names) 941 (stringconcatenate (map (lambda (name) (sprintf "<output name=\"~A\"/>~%" name)) names))) 942 943 (('input . names) 944 (stringconcatenate (map (lambda (name) 945 (match name 946 ((and name (? symbol?)) 947 (sprintf "<input name=\"~A\"/>~%" name)) 948 949 ((name 'from ns) 950 (sprintf "<input name=\"~A\" from=\"~A\"/>~%" name ns)) 951 952 )) 953 names))) 954 955 (('const name '= value) 956 (if (number? value) 957 (sprintf "<const name=\"~A\" value=\"~A\"/>~%" 958 name value) 959 (sprintf "<const name=\"~A\">~%~A~%</const>~%" 960 name value))) 961 962 (('defun name args body) 963 (sprintf "<defun name=\"~A\">~%~A~%<body>~A</body>~%</defun>~%" 964 name (stringconcatenate (map (lambda (x) (sprintf "<arg>~A</arg>" x)) args)) body)) 965 966 ((name '= expr) 967 (sprintf "<asgn name=\"~A\"><body>~A</body>~%</asgn>~%" 968 name expr)) 969 970 (('d ( name ) '= expr) 971 (sprintf "<rate name=\"~A\"><expr>~A</expr>~%</rate>~%" 972 name expr)) 973 974 (('d ( name ) '= expr ('initial initialexpr)) 975 (sprintf "<rate name=\"~A\"><expr>~A</expr>~%<initial>~A</initial>~%</rate>~%" 976 name expr initialexpr)) 977 978 (('hhionicgate 979 (ion 980 ('initialm initialmexpr) 981 ('initialh initialhexpr) 982 ('mpower mpower) 983 ('hpower hpower) 984 ('minf minfexpr) 985 ('mtau mtauexpr) 986 ('hinf hinfexpr) 987 ('htau htauexpr) 988 )) 989 990 (sprintf "<hh_ionic_gate name=\"~A\">~%<initial_m>~A</initial_m>~%<initial_h>~A</initial_h>~%<m_power>~A</m_power>~%<h_power>~A</h_power>~%<m_inf>~A</m_inf>~%<m_tau>~A</m_tau>~%<h_inf>~A</h_inf>~%<h_tau>~A</h_tau>~%</hh_ionic_gate>~%" 991 ion initialmexpr initialhexpr mpower hpower 992 minfexpr mtauexpr hinfexpr htauexpr)) 993 994 (('hhionicgate 995 (ion 996 ('initialm initialmexpr) 997 ('mpower mpower) 998 ('hpower hpower) 999 ('minf minfexpr) 1000 ('mtau mtauexpr) 1001 )) 1002 1003 (sprintf "<hh_ionic_gate name=\"~A\">~%<initial_m>~A</initial_m>~%<m_power>~A</m_power>~%<h_power>~A</h_power>~%<m_inf>~A</m_inf>~%<m_tau>~A</m_tau>~%</hh_ionic_gate>~%" 1004 ion initialmexpr mpower hpower 1005 minfexpr mtauexpr)) 1006 1007 (('hhionicgate 1008 (ion 1009 ('initialm initialmexpr) 1010 ('mpower mpower) 1011 ('hpower hpower) 1012 ('mtau mtauexpr) 1013 ('minf minfexpr) 1014 )) 1015 1016 (sprintf "<hh_ionic_gate name=\"~A\">~%<initial_m>~A</initial_m>~%<m_power>~A</m_power>~%<h_power>~A</h_power>~%<m_inf>~A</m_inf>~%<m_tau>~A</m_tau>~%</hh_ionic_gate>~%" 1017 ion initialmexpr mpower hpower 1018 minfexpr mtauexpr)) 1019 1020 (('hhionicgate 1021 (ion 1022 ('initialm initialmexpr) 1023 ('initialh initialhexpr) 1024 ('mpower mpower) 1025 ('hpower hpower) 1026 ('malpha malphaexpr) 1027 ('mbeta mbetaexpr) 1028 ('halpha halphaexpr) 1029 ('hbeta hbetaexpr) 1030 )) 1031 1032 (sprintf "<hh_ionic_gate name=\"~A\">~%<initial_m>~A</initial_m>~%<initial_h>~A</initial_h>~%<m_power>~A</m_power>~%<h_power>~A</h_power>~%<m_alpha>~A</m_alpha>~%<m_beta>~A</m_beta>~%<h_alpha>~A</h_alpha>~%<h_beta>~A</h_beta>~%</hh_ionic_gate>~%" 1033 ion initialmexpr initialhexpr mpower hpower 1034 malphaexpr mbetaexpr halphaexpr hbetaexpr)) 1035 1036 (('hhionicgate 1037 (ion 1038 ('initialm initialmexpr) 1039 ('mpower mpower) 1040 ('hpower hpower) 1041 ('malpha malphaexpr) 1042 ('mbeta mbetaexpr) 1043 )) 1044 1045 (sprintf "<hh_ionic_gate name=\"~A\">~%<initial_m>~A</initial_m>~%<m_power>~A</m_power>~%<h_power>~A</h_power>~%<m_alpha>~A</m_alpha>~%<m_beta>~A</m_beta>~%</hh_ionic_gate>~%" 1046 ion initialmexpr mpower hpower 1047 malphaexpr mbetaexpr)) 1048 1049 (('component ('type ty) ('name name) . rest) 1050 (sprintf "<component type=\"~A\" name=\"~A\">~%~A</component>~%" 1051 ty name (stringconcatenate (map entry>surfacexml rest)))) 1052 1053 (('component ('type ty) . rest) 1054 (sprintf "<component type=\"~A\">~%~A</component>~%" 1055 ty (stringconcatenate (map entry>surfacexml rest)))) 1056 1057 1058 (else (error 'nemo "unknown declaration" x)) 1059 )) 1060 1061 1062 1063 1064 929 1065 930 1066 (define (main opt operands) … … 934 1070 935 1071 (let ( 936 (models. iexpr1072 (models.modeldecls.iexpr 937 1073 (map (lambda (operand) 938 1074 (let* ((readxml (lambda (name) (callwithinputfile name … … 990 1126 (else (error 'nemo "unknown input format" informat)))) 991 1127 992 (model (case informat 993 ((sxml xml ixml) (ncml>model `((hhmarkov . ,(opt 'hhmarkov)) 994 (parseexpr . ,parseexpr)) 995 (car doc.iexpr))) 996 ((sexp) (sexp>model `((hhmarkov . ,(opt 'hhmarkov))) 997 (car doc.iexpr) parseexpr)) 998 ((nemo) (sexp>model `((hhmarkov . ,(opt 'hhmarkov))) 999 (car doc.iexpr) parseexpr)) 1000 (else (error 'nemo "unknown input format" informat)))) 1128 (model 1129 (case informat 1130 ((sxml xml ixml) (ncml>model `((hhmarkov . ,(opt 'hhmarkov)) 1131 (parseexpr . ,parseexpr)) 1132 (car doc.iexpr))) 1133 ((sexp) (sexp>model `((hhmarkov . ,(opt 'hhmarkov))) 1134 (car doc.iexpr) parseexpr)) 1135 ((nemo) (sexp>model `((hhmarkov . ,(opt 'hhmarkov))) 1136 (car doc.iexpr) parseexpr)) 1137 (else (error 'nemo "unknown input format" informat)))) 1001 1138 ) 1002 (cons model (cdr doc.iexpr)))) 1139 (cons model doc.iexpr) 1140 )) 1003 1141 operands))) 1004 1142 (foreach 1005 (lambda (operand model.iexpr) 1006 1007 (matchlet ((($ nemo:quantity 'DISPATCH dis) (hashtableref (car model.iexpr) (nemointern 'dispatch)))) 1143 (lambda (operand model.modeldecls.iexpr) 1144 1145 (matchlet* (((model modeldecls . iexpr?) 1146 model.modeldecls.iexpr) 1147 (($ nemo:quantity 'DISPATCH dis) 1148 (hashtableref model (nemointern 'dispatch))) 1149 ) 1008 1150 1009 (let* ((model (car model.iexpr)) 1010 (iexpr? (cdr model.iexpr)) 1011 1151 (let* ( 1012 1152 (sysname ((dis 'sysname) model)) 1013 1153 (dirname (pathnamedirectory operand)) 1014 1154 (sxmlfname (makeoutputfname dirname sysname ".sxml" (opt 'sxml) )) 1155 (surfacexmlfname (makeoutputfname dirname sysname ".xml" (opt 'surfacexml) )) 1015 1156 (xmlfname (makeoutputfname dirname sysname ".xml" (opt 'xml) )) 1016 1157 (modfname (makeoutputfname dirname sysname ".mod" (opt 'nmodl) )) … … 1077 1218 1078 1219 ) 1079 (if sxmlfname (withoutputtofile sxmlfname 1080 (lambda () (prettyprint (model>ncml model parseexpr))))) 1081 (if xmlfname (let* ((doc (model>ncml model parseexpr)) 1082 (doc1 (ensurexmlns 1083 (cond ((eq? (car doc) '*TOP*) (assoc 'ncml:model (cdr doc))) 1084 (else doc))))) 1085 (withoutputtofile xmlfname 1086 (lambda () (printfragments (generateXML `(begin ,doc1))))))) 1220 1221 (if (and xmlfname surfacexmlfname) 1222 (error 'nemo "both xml and surfacexml options are not permitted")) 1223 1224 (if sxmlfname 1225 (withoutputtofile sxmlfname 1226 (lambda () (prettyprint (model>ncml model parseexpr))))) 1227 1228 (if xmlfname 1229 (let* ((doc (model>ncml model parseexpr)) 1230 (doc1 (ensurexmlns 1231 (cond ((eq? (car doc) '*TOP*) (assoc 'ncml:model (cdr doc))) 1232 (else doc))))) 1233 (withoutputtofile xmlfname 1234 (lambda () (printfragments (generateXML `(begin ,doc1))))))) 1235 1236 1237 (if surfacexmlfname 1238 (withoutputtofile surfacexmlfname 1239 (lambda () (printfragments (entry>surfacexml modeldecls))))) 1240 1087 1241 (if modfname 1088 1242 (withoutputtofile … … 1112 1266 1113 1267 ))) 1114 operands models. iexpr)1268 operands models.modeldecls.iexpr) 1115 1269 1116 1270 (let ((pyparams (opt 'pyparams)))
Note: See TracChangeset
for help on using the changeset viewer.