
    5i6S                        d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
Z
d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZmZm Z m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z' 	 d dl(Z( e(jR                           ejT                  d	      Z+d
Z,dZ-dZ.dZ/ ej`                  d      Z1e1je                  dd       e1je                  dd       e1je                  dg ddd       e1je                  ddd       e1jg                         Z4e4jj                  Cejl                  jo                  e4jj                        se1jq                  de4jj                  z          d Z9e:d k(  r e9        yy#  Y xY w)!    )print_functionunicode_literalsN)OrderedDict)print_introget_nameget_versionget_metadata	Completerget_ordinal_strprompt_for_varprompt_for_ynuse_completerget_languagelanguage_optionsget_patternget_timeoutfill_in_name_and_vercleancreate_files_from_templates)fillBOLD	UNDERLINEDNANEXUS_LOGOENDC)APP_CATEGORIES)InstanceTypesCompleter)format_tablez^[a-zA-Z_][0-9a-zA-Z_]*$zaws:us-east-1zazure:westuszoci:us-ashburn-1z1.0.0zCreate a source code directory for a DNAnexus app.  You will be prompted for various metadata for the app as well as for its input and output specifications.)descriptionz--json-filez4Use the metadata and IO spec found in the given file)helpz
--languagez Programming language of your appz
--template)basicparallelizedscatter-process-gatherr    zExecution pattern of your app)choicesdefaultr   namezName of your app?)r   nargszFile not found: c                  $    g }t        t               t        j                  t	        t        j                  d      5 }t        j                  |j                               }t        t        j                  xs |j                  d            }||d<   t        |j                  d            }||d<   ddd       	 t        j                  d          ntt        t        j                        }	 t        j                  |       t'        t              \  }}t               }t)               }||d<   |xs ||d	<   |xs ||d
<   t        |d<   ||d<   t+        g d      }t+        ddg      }	t-        d       t-        t/               dz   t1               z          t-        d       d}
g }d}|
rg |d<   t-        t#        d             	 t-        d       t3        t5        |d         dz         }t7        |dz   d      }|dk(  rn||v rt-        t#        d             Vt8        j;                  |      st-        t#        d             |j=                  |       t7        dd      }t?        |       |st-        d       t-        d       d}	 t7        d      }||j@                  v rnt-        t#        d             /t?                tC        d      }d}|r|dv rtC        d       }|rw	 |d!k(  r%t?        |	       t7        d"ddg#      }t?                n|d$k(  rt7        d"d      }nt7        d"      }	 |d!k(  r|dk(  }n!|d%k(  rtE        |      }n|d&k(  rtG        |      }nd}t)               }||d<   |dk7  r||d(<   ||d)<   ||d*<   |||d+<   |d,k(  s|d-k(  rd.g|d/<   d|d0<   |d   j=                  |       t-        d       t-        t/               d1z   t1               z          t-        d       d}g }|r^g |d2<   t-        t#        d3             	 t-        d       t3        t5        |d2         dz         }t7        |d4z   d      }|dk(  rn||v rt-        t#        d5             Vt8        j;                  |      st-        t#        d             |j=                  |       t7        dd      }t?        |       |st-        d6       t-        d7       d}	 t7        d      }||j@                  v rnt-        t#        d             /t?                t)               }||d<   |dk7  r||d(<   ||d)<   |d,k(  s|d-k(  rd.g|d/<   d|d0<   |d2   j=                  |       Dg }g }g }g }g }d|v rX|d   D ]P  }|j                  d*      xr d+|v}|d)   d,k(  r|r|n|} n|d)   d-k(  r|r|n|} nd} | =| j=                  |d          R d2|v r|d2   D cg c]  }|d)   d,k(  s|d    }}t-        d       t-        t/               d8z   t1               z          t)        i       |d9<   |d9   jI                  d:i        tK        |d9   d:   j                  d.            \  }!}"|d9   d:   jI                  d.i        |d9   d:   d.   jI                  |"|!       t-        d       t-        t/               d;z   t1               z          t        jL                  t        jL                  n	tO               }#tP        |#   jS                         }$|$|d9   d<<   t        jT                  jW                  t        jT                  jY                  tZ        j\                        d=d>tP        |#   j_                               }%t        jT                  ja                  t        jT                  jW                  |%t        jb                              s4t-        t#        d?t        jb                  z   d@z                te        |%      }&nt        jb                  }&t        jT                  jW                  |%|&      }%t	        t        jT                  jW                  |%dA      d      5 }'tg        |'j                               }(t        j                  |(      })|)d9   D ]  }*|)d9   |*   |d9   |*<    	 ddd       |#t        jL                  k(  r|&t        jb                  k(  rt-        dB       t-        d       t-        t/        dC             t-        t#        dDt/        dE      z   dFz                t-        d       t-        t#        ti        dG      dHz                tC        dId      r>|jI                  dJi        d.g|dJ   dK<   t-        t#        dLti        dM      z   dNz                t-        d       t-        t#        ti        dO      dPz                tC        dQd      rL|jI                  dJi        dR|dJ   dS<   t-        t#        dTti        dU      z   dVz   ti        dW      z   dXz                t-        d       t-        t/        dY             t-        d       t-        t/        dZ             t-        tk        tl        jn                  jq                         ts        tl        jn                  jq                               d[   jt                  \             t-        t/        d]             t-        tk        tl        jv                  jq                         ts        tl        jv                  jq                               d[   jt                  \             t-        t/        d^             t-        tk        tl        jx                  jq                         ts        tl        jx                  jq                               d[   jt                  \             t-        t#        t/        d_      d`z   daz   t/        db      z   dcz                t?        tm                      t7        ddtl        jz                  j|                  ts        tl        j~                        e      }+t        },|+tl        jv                  j                         v rt        },n&|+tl        jx                  j                         v rt        },t)        i       |df<   t)        i       |df   |,<   |df   |,   jI                  dgi        |df   |,   dg   jI                  d.i        |+|df   |,   dg   d.   dh<   di|d9   dj<   dk|d9   dl<   dm|d9   d<   t-        d       t-        t/               dnz   t               z   t/               z   doz   t1               z          t	        t        jT                  jW                  dA      dp      5 }-|-j!                  t        t        j                  |dqr            dz          ddd       |j=                  t        jT                  jW                  |dA             t-        d       t-        t#        dsd|v rd2|v sdtndz                t-        d       duD ]f  }.	 t        j                  t        jT                  jW                  ||.             |j=                  t        jT                  jW                  ||.d             h dxg}/|&dyk(  rg dz}/n	|&d{k(  rg d|}/|t        |%||#||||||&d}|/~      z  }t-        d       t        |      D ]  }0t-        d|0        t-        dt#        dj                  |            z   dz          t-        t#        dt/               z   dz   t1               z   dz                y# 1 sw Y   DxY w#  t        j                  j!                  t#        dd   z        dz          t        j$                  d       Y 
xY w#  t        j                  j!                  t#        d|z        dz          t        j$                  d       Y xY w#  t-        d'|z          Y nxY wc c}w # 1 sw Y   GxY w# 1 sw Y   [xY w#  t        j                  j!                  dv|dw|.       t        j$                  d       Y 5xY w)z}
    Entry point for dx-app-wizard.
    Note that this function is not meant to be used as a subroutine in your program.
    Nrr%   )r$   versionzUnable to create a directory for %s, please check that it is a valid app name and the working directory exists and is writable.
   titlesummarydxapi)intfloatstringbooleanhashz	array:intzarray:floatzarray:stringzarray:booleanrecordfileappletzarray:record
array:filezarray:applettruefalse zInput SpecificationTF	inputSpeczYou will now be prompted for each input parameter to your app.  Each parameter should have a unique name that uses only the underscore "_" and alphanumeric characters, and does not start with a number.z input name (<ENTER> to finish))allow_emptyzLError: Cannot use the same input parameter name twice.  Please choose again.zError: Parameter names may use only underscore "_", ASCII letters, and digits; and may not start with a digit.  Please choose again.z$Label (optional human-readable name)z=Your input parameter must be of one of the following classes:zapplet         array:file     array:record   file           int
array:applet   array:float    array:string   float          record
array:boolean  array:int      boolean        hash           string
z(Choose a class (<TAB> twice for choices)z,Not a recognized class; please choose again.zThis is an optional parameter)r0   r1   r2   r3   z"A default value should be providedr3   z  Default value)r#   r2   r0   r1   z.Not a valid default value for the given class labelclassoptionalr$   r6   r8   *patternsr   zOutput Specification
outputSpeczYou will now be prompted for each output parameter of your app.  Each parameter should have a unique name that uses only the underscore "_" and alphanumeric characters, and does not start with a number.z  output name (<ENTER> to finish)zMError: Cannot use the same output parameter name twice.  Please choose again.z>Your output parameter must be of one of the following classes:zapplet         array:file     array:record   file           int
array:applet   array:float    array:string   float          record
array:boolean  array:int      boolean        hash           stringzTimeout PolicyrunSpectimeoutPolicyzTemplate Optionsinterpreter
templating	templateszThe execution pattern "z1" is not available for your programming language.z
dxapp.jsonz3All template options are supplied in the arguments.zAccess PermissionszIf you request these extra permissions for your app, users will see this fact when launching your app, and certain other restrictions will apply. For more information, see zAhttps://documentation.dnanexus.com/developer/apps/app-permissions.zAccess to the Internetz) (other than accessing the DNAnexus API).z*Will this app need access to the Internet?accessnetworkzRApp has full access to the Internet. To narrow access to specific sites, edit the zaccess.networkz. field of dxapp.json once we generate the app.z#Direct access to the parent projectzv. This is not needed if your app specifies outputs,
    which will be copied into the project after it's done running.z0Will this app need access to the parent project?
CONTRIBUTEprojectzzApp has CONTRIBUTE access to the parent project. To change the access level or request access to other projects, edit the zaccess.projectz and zaccess.allProjectsz/ fields of dxapp.json once we generate the app.zSystem RequirementszCommon AWS instance types:r   )column_nameszCommon Azure instance types:zCommon OCI instance types:zDefault instance type:zE The instance type you select here will apply to all entry points in z%your app unless you override it. See zPhttps://documentation.dnanexus.com/developer/api/running-analyses/instance-typesz for more information.z$Choose an instance type for your app)r$   r#   regionalOptionssystemRequirementsinstanceTypeUbuntudistributionz24.04release0z*** Generating z App Template... ***w   )indentzYour app specification has been written to the
dxapp.json file. You can specify more app options by editing this file
directly (see https://documentation.dnanexus.com/developer for complete
documentation).z  Note that without an input and output specification,
your app can only be built as an APPLET on the system.  To publish it to
the DNAnexus community, you must first specify your inputs and outputs.
)srctest	resourceszUnable to create subdirectory /mainr!   )r]   processpostprocessr"   )r]   scattermapr^   r_   z.<!-- Insert a description of your app here -->)r   entry_pointszCreated files:	zApp directory created!  See
https://documentation.dnanexus.com/developer for tutorials on how to modify these files,
or run "dx build {n}" or "dx build --create-app {n}" while logged in with dx.)nzoRunning the DNAnexus build utility will create an executable on the DNAnexus platform.  Any files found in the r[   zj directory will be uploaded so that they will be present in the root directory when the executable is run.)Jr   API_VERSIONargs	json_fileopenjsonloadsreadr   r%   getr   osmkdirsysstderrwriter   exitr	   r   r
   printr   r   r   lenr   IO_NAME_PATTERNmatchappendr   r#   r   r0   r1   
setdefaultr   languager   r   get_interpreterpathjoindirnamedxpy__file__get_pathisdirtemplater   r   r   r   r   aws_preferred_instance_typesvalueslist_fieldsazure_preferred_instance_typesoci_preferred_instance_typesdefault_instance_typeNameinstance_typesDEFAULT_REGION_AWSkeysDEFAULT_REGION_AZUREDEFAULT_REGION_OCIr   r   dumpsr   sortedformat)1kwargsmanifestrg   app_jsonr%   r*   r-   r.   class_completerbool_completer
input_specinput_namesprinted_classesordinal
input_nameinput_labelinput_classr@   default_valparameter_jsonoutput_specoutput_namesoutput_nameoutput_labeloutput_classrequired_file_input_namesoptional_file_input_namesrequired_file_array_input_namesoptional_file_array_input_namesfile_output_namesparammay_be_missing
param_listtimeouttimeout_unitsry   rF   template_dirpatterntemplate_app_json_file	file_texttemplate_app_jsonkeyinstance_typetarget_region	prog_filesubdirrb   filenames1                                                    |/home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/scripts/dx_app_wizard.pyr]   r]   ;   s   
 H~~!$..#& 	*)zz).."23HDII$Ef1EFD#HV!(,,y*ABG")HY	*	HHXf%& 		*	HHTN
 &k2w-=!MT%o'% $ %S T #FG#45b	df,,tv56b	
$&H[!$  c  d  eb	)#h{.C*Dq*HI+G6W,Weij
#,$mno&,,Z8$   f  g  h"":.,-SUWXo.&YZ   '+O"01["\K"o&=&==d#QRS  ()HI"/T T"/0T"UK""*i7 -n =.<=NY_ahXi.j -!,!8.<=N\`.a.<=N.O	f#.)#;3>&3HK%0E%925k2BK%0G%;272DK % '+ "-)3v&"$.9N7+*5w'-5z**0;N9- &(K<,G25N:.)+v&%,,^<_ b 	b	df--67b	%'H\"$  d  e  fb	)#h|.D*E*IJ,W7Y-Ygkl"$,.$nop&,,[9$   f  g  h##K0-.TVXYo.&Z[ F G '+O#12\#]L#'>'>>d#QRS   "-)4v&2%.:N7+*6w'  6)\\-I25N:.)+v&&--n=Y \ !# "&(#&(#hk* 		1E"YYz2My7MNW~':H6Ng
w</@N<Ts
!
%!!%-0		1 x8@8NkuRWX_R`djRjU6]kk 
"I	$&#
#df
,-%b/HYY""?B7()1D_1U1Y1YZ]1^_G]Y(33C<Y(-88P 
"I	$&%
%
./ !% 9t}}|~H"8,<<>K)4HY& 77<< >k[klt[u[~[~  \A  BL77==lDMMBCd,t}}<?rrstl+--77<<g6L	bggll<6	< I@V()?)D)D)FgV	 JJy1$Y/ 	IC'8'CC'HHY$	II 	DMM!4==(@CD 
"I	$#
$%	$  B	LMNPST U V 
"I	$y125``
abA5QHb)),9%dg-./1ab c 	d 
"I	$y>? CF F G HGQVWHb)(49%d /1:;K1LMOVWYbcwYxyDE F 	G 
"I	$$
%&	"I	$+
,-	,-JJQQS$()?)\)\)c)c)e$fgh$i$q$qs t	$-
./	,-LLSSU$()?)^)^)e)e)g$hij$k$s$su v	$+
,-	,-JJQQS$()?)\)\)c)c)e$fgh$i$q$qs t	$t,-0ww67fgh kCC D E (*+"#I+A+W+W+\+\+/0F0U0U+VXM 'M.MMRRTT,	0MMRRT	T*"-b/H1<RH..99:NPRS./CDOOPSUWX\iH./CDSI.Y +3HY'%,HY	"%(HY	" 
"I	$&$
$}
6
?BX
X[_[a
ab	bggll4.	4 F	djj!<=DEFOOBGGLL|45	"I	$  8#(@ HJK L M 
"I, 	HHRWW\\$/0OOBGGLLvr:; 8L. 9	,	,K+L(H,EG`,KMl,=w8h9EG GH 

8$ dH	$ QQWQWZ^QWQ_a acgh i 
$  EF !#'6*|} ~ C	* 	*	JJT  #h  ks  tz  k{  #{  |  C  C  DHHQK	JJT  #h  ko  #o  p  sw  w  xHHQK~f %&VYd&d e' #h lPI InF F$	JJdFSTHHQKse   A6{4;| 0} ),~ :~1~1'A	~673A#4{>A}A~~,6 <A@__main__);
__future__r   r   ro   rm   ri   argparserecollectionsr   r~   dxpy.templating.utilsr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   dxpy.utils.printingr   r   r   r   r   dxpy.app_categoriesr   dxpy.utils.completerr   dxpy.utils.pretty_printr   coloramainitcompileru   r   r   r   re   ArgumentParserparseradd_argument
parse_argsrf   rg   r{   existserrorr]   __name__     r   <module>r      sh  & :    	 # w w w w w K J . 7 0	HMMO "**78$ % ' 	 	 	   .M  
N   M(^  _   L'I  J   LOY`8  :   F!33  ?>>bggnnT^^&D
LL#dnn45M^ zF I	s   ,E/ /E3