-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeProject.bat
More file actions
196 lines (185 loc) · 5.29 KB
/
Copy pathmakeProject.bat
File metadata and controls
196 lines (185 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@echo off
rem ------------------------------------- pISA-tree v.0.4.2
rem
rem Create a new project tree _p_xxx in current directory
rem ------------------------------------------------------
rem Author: A Blejec <andrej.blejec@nib.si>
rem (c) National Institute of Biology, Ljubljana, Slovenia
rem 2016
rem ------------------------------------------------------
rem cd d:\_X
rem Backup copy if the folder exists
rem robocopy %ID% X-%ID% /MIR
rem ------------------------------------------------------
echo =============================
echo pISA-tree: make PROJECT
echo -----------------------------
set descFile=".\_PROJECT_METADATA.TXT"
rem Ask for study ID, loop if empty
set ID=""
if "%1" EQU "" (
rem echo @
set /p ID=Enter project ID:
rem echo %ID%
) else (
set ID=%1
)
:Ask
echo za ask
if %ID% EQU "" set /p ID=Enter project ID:
if %ID% EQU "" goto Ask
REM Check existence/uniqueness
IF EXIST _p_%ID% (
REM Dir exists
echo ERROR: project named *%ID%* already exists
set ID=""
goto Ask
) ELSE (
REM Continue creating directory
echo Creating project %ID%
)
rem ----------------------------------------------
rem Make new project directory tree
rem set project root
rem set PPath=:getparentdir %cd%
rem set \ to /
rem set "PPath=!PPath:\=/!"
rem echo %PPath%
rem
set pdir=_p_%ID%
md %pdir%
cd %pdir%
set proot=%cd%
set mroot=".."
md presentations
md reports
rem put something to the directories
rem to force git to add them
REM
echo # Project %ID% > .\README.MD
echo # Reports for project %ID% > .\reports\README.MD
echo # Presentations for project %ID% > .\presentations\README.MD
echo # Describe samples > .\phenodata.txt
echo # Feature Summary Table> .\FST.txt
rem
setlocal EnableDelayedExpansion
set LF=^
REM Two empty lines are necessary
::Create a TAB variable
REM not really needed
rem call:hexprint "0x09" TAB
rem -----------------------------------------------
call:getLayer _p_ pname
REM -----------------------------------------------
REM echo SHORT NAME !LF!DESCRIPTION !LF!INVESTIGATOR !LF!PROJECT !LF!FITOBASE LINK !LF!RAW DATA !LF!> .\_experiments\_EXPERIMENT_METADATA.TXT
echo project: %pname%> %descFile%
echo ### PROJECT>> %descFile%
echo Short Name: %ID%>> %descFile%
call:inputMeta "Title" aTitle *
call:inputMeta "Description" aDesc *
echo Project Path: %cd% >> %descFile%
copy %descFile%+..\common.ini %descFile%
copy ..\common.ini .
rem copy bla.tmp %descFile%
echo ##### INVESTIGATIONS!LF!>> %descFile%
rem
rem make main readme.md file
copy %mroot%\makeInvestigation.bat .
copy %mroot%\showTree.bat .
copy %mroot%\showMetadata.bat .
copy %mroot%\xcheckMetadata.bat .
type README.MD
del *.tmp
dir.
type %descFile%
cd..
rem copy existing files from nonversioned tree (if any)
rem robocopy X-%ID% %ID% /E
rem dir .\%ID% /s/b
rem pause
goto:eof
rem --------------------------------------------------------
rem Functions
:getInput --- get text from keyboard
:: --- %~1 Input message (what o type
:: --- %~2 Variable to get result
:: --- %~3 (optional) missing: input required
:: --- * : can be skipped, return *
:: Example: call:getInpt "Type something" xx default
SETLOCAL
:Aski
set x=%~3
set /p x=Enter %~1 [%x%]:
rem if %x% EQU "" set x="%~3"
if "%x%" EQU "" goto Ask
REM Check existence/uniqueness
if "%x%" EQU "*" goto done
IF EXIST "%x%" (
REM Dir exists
echo ERROR: %~1 *%x%* already exists
set x=""
goto Aski
)
:done
(ENDLOCAL
set "%~2=%x%"
)
GOTO:EOF
rem -----------------------------------------------------
rem Get parent dir
rem
:getparentdir
if "%~1" EQU "" goto :EOF
Set ParentDir=%~1
shift
goto :getparentdir
rem -----------------------------------------------------
:inputMeta --- get metadata and append to descFile
:: --- descFile - should be set befor the call
:: --- %~1 Input message (what to enter)
:: --- %~2 Variable to get result
:: --- %~3 (optional) missing: input required
:: --- * : can be skipped, return *
:: Example: call:putMeta "Type something" xx default
SETLOCAL
rem call:getInput "%~1" xMeta "%~3"
rem Type input or get menu?
call:getInput "%~1" xMeta "%~3"
echo %~1: %xMeta% >> %descFile%
rem call:writeAnalytes %analytesInput% "%~1" %xMeta%
rem
rem
(ENDLOCAL
IF "%~2" NEQ "" set "%~2=%xMeta%"
set "aEntered=%xMeta%"
)
GOTO:EOF
REM ------------------------------------------------------
:hexPrint string [rtnVar]
for /f eol^=^%LF%%LF%^ delims^= %%A in (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"'
) do if "%~2" neq "" (set %~2=%%A) else echo(%%A
GOTO:EOF
rem -----------------------------------
:getLayer --- get layer name from the current path
:: --- %~1 layer prefix (e.g. _I_)
:: --- %~2 Variable to get result
:: To remove characters from the right hand side of a string is
:: a two step process and requires the use of a CALL statement
:: e.g.
SET _test=D:\bla\_p_project\_I_test\_S_moj
SET _test=%cd%
SETLOCAL EnableDelayedExpansion
:: To delete everything after the string e.g. '_I_'
:: first delete .e.g. '_I_' and everything before it
SET _test=!_test:*\%~1=%~1!
SET _endbit=%_test:*\=%
REM Echo We dont want: [%_endbit%]
::Now remove this from the original string
CALL SET _result=%%_test:\%_endbit%=%%
rem echo %_result%
(endlocal
set "%~2=%_result%")
rem echo %iname%
endlocal
goto :eof