HTPolyNet 1.0.7.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- HTPolyNet/__init__.py +1 -0
- HTPolyNet/ambertools.py +94 -0
- HTPolyNet/analyze.py +258 -0
- HTPolyNet/banner.py +26 -0
- HTPolyNet/bondlist.py +206 -0
- HTPolyNet/bondtemplate.py +111 -0
- HTPolyNet/checkpoint.py +88 -0
- HTPolyNet/command.py +42 -0
- HTPolyNet/configuration.py +240 -0
- HTPolyNet/coordinates.py +1071 -0
- HTPolyNet/countTime.py +26 -0
- HTPolyNet/curecontroller.py +767 -0
- HTPolyNet/dataframetools.py +130 -0
- HTPolyNet/driver.py +250 -0
- HTPolyNet/expandreactions.py +154 -0
- HTPolyNet/gromacs.py +333 -0
- HTPolyNet/inputcheck.py +51 -0
- HTPolyNet/linkcell.py +322 -0
- HTPolyNet/molecule.py +1279 -0
- HTPolyNet/plot.py +607 -0
- HTPolyNet/postsim.py +444 -0
- HTPolyNet/projectfilesystem.py +483 -0
- HTPolyNet/reaction.py +282 -0
- HTPolyNet/resources/README.md +20 -0
- HTPolyNet/resources/__init__.py +0 -0
- HTPolyNet/resources/cfg/DGE-PAC-hi.yaml +115 -0
- HTPolyNet/resources/cfg/DGE-PAC-lo.yaml +115 -0
- HTPolyNet/resources/cfg/FDE-DFDA-hi.yaml +116 -0
- HTPolyNet/resources/cfg/FDE-DFDA-lo.yaml +116 -0
- HTPolyNet/resources/cfg/GMASTY-hi.yaml +158 -0
- HTPolyNet/resources/cfg/GMASTY-lo.yaml +158 -0
- HTPolyNet/resources/cfg/README.md +1 -0
- HTPolyNet/resources/cfg/STY.yaml +23 -0
- HTPolyNet/resources/cfg/pMSTY-hi.yaml +101 -0
- HTPolyNet/resources/cfg/pMSTY-lo.yaml +101 -0
- HTPolyNet/resources/cfg/pSTY-hi.yaml +101 -0
- HTPolyNet/resources/cfg/pSTY-lo.yaml +101 -0
- HTPolyNet/resources/example_depot/0-liquid-styrene.tgz +0 -0
- HTPolyNet/resources/example_depot/1-polystyrene.tgz +0 -0
- HTPolyNet/resources/example_depot/2-polymethylstyrene.tgz +0 -0
- HTPolyNet/resources/example_depot/3-bisgma-styrene-thermoset.tgz +0 -0
- HTPolyNet/resources/example_depot/4-pacm-dgeba-epoxy-thermoset.tgz +0 -0
- HTPolyNet/resources/example_depot/5-dfda-fde-epoxy-thermoset.tgz +0 -0
- HTPolyNet/resources/mdp/README.md +1 -0
- HTPolyNet/resources/mdp/drag-min.mdp +13 -0
- HTPolyNet/resources/mdp/drag-npt.mdp +36 -0
- HTPolyNet/resources/mdp/drag-nvt.mdp +31 -0
- HTPolyNet/resources/mdp/min.mdp +14 -0
- HTPolyNet/resources/mdp/npt.mdp +37 -0
- HTPolyNet/resources/mdp/nvt.mdp +29 -0
- HTPolyNet/resources/mdp/relax-min.mdp +13 -0
- HTPolyNet/resources/mdp/relax-npt.mdp +37 -0
- HTPolyNet/resources/mdp/relax-nvt.mdp +31 -0
- HTPolyNet/resources/mdp/single-molecule-min.mdp +12 -0
- HTPolyNet/resources/mdp/single-molecule-nvt.mdp +25 -0
- HTPolyNet/resources/molecules/inputs/DFA.pdb +62 -0
- HTPolyNet/resources/molecules/inputs/DGE.mol2 +115 -0
- HTPolyNet/resources/molecules/inputs/EMB.mol2 +50 -0
- HTPolyNet/resources/molecules/inputs/FDE.pdb +72 -0
- HTPolyNet/resources/molecules/inputs/GMA.mol2 +163 -0
- HTPolyNet/resources/molecules/inputs/PAC.mol2 +91 -0
- HTPolyNet/resources/molecules/inputs/STY.mol2 +44 -0
- HTPolyNet/resources/molecules/make-monomers.sh +64 -0
- HTPolyNet/resources/molecules/pics/DFA.png +0 -0
- HTPolyNet/resources/molecules/pics/DGE.png +0 -0
- HTPolyNet/resources/molecules/pics/EMB.png +0 -0
- HTPolyNet/resources/molecules/pics/FDE.png +0 -0
- HTPolyNet/resources/molecules/pics/GMA.png +0 -0
- HTPolyNet/resources/molecules/pics/PAC.png +0 -0
- HTPolyNet/resources/molecules/pics/STY.png +0 -0
- HTPolyNet/resources/molecules/sample-inputs/DFA.pdb +62 -0
- HTPolyNet/resources/molecules/sample-inputs/DGE.mol2 +115 -0
- HTPolyNet/resources/molecules/sample-inputs/EMB.mol2 +50 -0
- HTPolyNet/resources/molecules/sample-inputs/FDE.pdb +72 -0
- HTPolyNet/resources/molecules/sample-inputs/GMA.mol2 +163 -0
- HTPolyNet/resources/molecules/sample-inputs/PAC.mol2 +91 -0
- HTPolyNet/resources/molecules/sample-inputs/STY.mol2 +44 -0
- HTPolyNet/resources/tcl/readbonds.tcl +32 -0
- HTPolyNet/resources/tcl/readgrx.tcl +46 -0
- HTPolyNet/resources/tcl/render.tcl +74 -0
- HTPolyNet/ring.py +155 -0
- HTPolyNet/runtime.py +709 -0
- HTPolyNet/software.py +106 -0
- HTPolyNet/stringthings.py +39 -0
- HTPolyNet/topocoord.py +1877 -0
- HTPolyNet/topology.py +1288 -0
- HTPolyNet/unused_symmetry_stuff.py +291 -0
- HTPolyNet/utils.py +405 -0
- htpolynet-1.0.7.2.dist-info/METADATA +84 -0
- htpolynet-1.0.7.2.dist-info/RECORD +93 -0
- htpolynet-1.0.7.2.dist-info/WHEEL +4 -0
- htpolynet-1.0.7.2.dist-info/entry_points.txt +2 -0
- htpolynet-1.0.7.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
.. module:: projectfilesystem
|
|
4
|
+
:synopsis: handles project filesystems
|
|
5
|
+
|
|
6
|
+
.. moduleauthor: Cameron F. Abrams, <cfa22@drexel.edu>
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
import shutil
|
|
10
|
+
import logging
|
|
11
|
+
import os
|
|
12
|
+
import glob
|
|
13
|
+
from . import resources
|
|
14
|
+
logger=logging.getLogger(__name__)
|
|
15
|
+
excludes=['__pycache__','__init__.py']
|
|
16
|
+
class RuntimeLibrary:
|
|
17
|
+
''' a library object -- default creation references the Library resource package. '''
|
|
18
|
+
def __init__(self):
|
|
19
|
+
self.root=''
|
|
20
|
+
# self.subdirs=[]
|
|
21
|
+
self.designation=''
|
|
22
|
+
self.ResourcePaths={}
|
|
23
|
+
@classmethod
|
|
24
|
+
def system(cls):
|
|
25
|
+
"""system generates a RuntimeLibrary object corresponding to the installed Library subpackage
|
|
26
|
+
|
|
27
|
+
:param libpackage: name of the HTPolyNet Library subpackage, defaults to 'Library'
|
|
28
|
+
:type libpackage: str, optional
|
|
29
|
+
:raises ImportError: if the system library subpackage is not found
|
|
30
|
+
:return: a RuntimeLibrary object holding the system library subpackage
|
|
31
|
+
:rtype: RuntimeLibrary
|
|
32
|
+
"""
|
|
33
|
+
inst=cls()
|
|
34
|
+
inst.designation='System'
|
|
35
|
+
inst.root=os.path.dirname(resources.__file__)
|
|
36
|
+
ResourceFullPaths=glob.glob(inst.root+'/*')
|
|
37
|
+
for l in ResourceFullPaths:
|
|
38
|
+
bn=os.path.basename(l)
|
|
39
|
+
if not bn in excludes:
|
|
40
|
+
inst.ResourcePaths[bn]=l
|
|
41
|
+
logger.info(inst.info())
|
|
42
|
+
return inst
|
|
43
|
+
|
|
44
|
+
def get_example_depot_location(self):
|
|
45
|
+
"""get_example_depot_location reports the location of the examples in this RuntimeLibrary, if they exist
|
|
46
|
+
|
|
47
|
+
:return: name of depot directory
|
|
48
|
+
:rtype: str
|
|
49
|
+
"""
|
|
50
|
+
assert 'example_depot' in self.ResourcePaths,f'No example depot found in {self.root} -- your installation is corrupt.'
|
|
51
|
+
return self.ResourcePaths['example_depot']
|
|
52
|
+
|
|
53
|
+
def get_example_names(self):
|
|
54
|
+
"""get_example_names returns the names of the example tarballs
|
|
55
|
+
|
|
56
|
+
:return: list of names of example tarballs
|
|
57
|
+
:rtype: list
|
|
58
|
+
"""
|
|
59
|
+
depot=self.get_example_depot_location()
|
|
60
|
+
assert os.path.exists(depot) and os.path.isdir(depot),f'Depot not found or not a directory -- your installation is corrupt.'
|
|
61
|
+
owd=os.getcwd()
|
|
62
|
+
os.chdir(depot)
|
|
63
|
+
example_tarballs=glob.glob('*.tgz')
|
|
64
|
+
basenames=[x.replace('.tgz','') for x in example_tarballs]
|
|
65
|
+
basenames.sort()
|
|
66
|
+
os.chdir(owd)
|
|
67
|
+
return basenames
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def user(cls,pathname='.'):
|
|
71
|
+
"""user generates a new user-level RuntimeLibrary object
|
|
72
|
+
|
|
73
|
+
:param pathname: where to find the library, defaults to '.'
|
|
74
|
+
:type pathname: str, optional
|
|
75
|
+
:return: a new RuntimeLibrary object
|
|
76
|
+
:rtype: RuntimeLibrary
|
|
77
|
+
"""
|
|
78
|
+
if not pathname:
|
|
79
|
+
return None
|
|
80
|
+
assert os.path.exists(pathname),f'Cannot find {pathname} in {os.getcwd()}'
|
|
81
|
+
tt=os.path.abspath(pathname)
|
|
82
|
+
assert os.path.isdir(tt),f'Please ensure that {str(tt)} is a directory'
|
|
83
|
+
inst=cls()
|
|
84
|
+
inst.designation='User'
|
|
85
|
+
inst.root=tt
|
|
86
|
+
ResourceFullPaths=glob.glob(inst.root+'/*')
|
|
87
|
+
for l in ResourceFullPaths:
|
|
88
|
+
bn=os.path.basename(l)
|
|
89
|
+
if not bn in excludes:
|
|
90
|
+
inst.ResourcePaths[bn]=l
|
|
91
|
+
return inst
|
|
92
|
+
|
|
93
|
+
def checkin(self,filename,overwrite=False):
|
|
94
|
+
"""checkin check filename into this RuntimeLibrary
|
|
95
|
+
|
|
96
|
+
:param filename: name of file to check in, ***relative to the top level directory in which the library is housed***
|
|
97
|
+
:type filename: str
|
|
98
|
+
:param overwrite: if True, overwrite the file in the RuntimeLibrary if it exists, defaults to False
|
|
99
|
+
:type overwrite: bool, optional
|
|
100
|
+
:return: False if filename not found in cwd; True if check-in was successful
|
|
101
|
+
:rtype: bool
|
|
102
|
+
"""
|
|
103
|
+
basefilename=os.path.basename(filename)
|
|
104
|
+
if not os.path.exists(basefilename):
|
|
105
|
+
logger.debug(f'{basefilename} not found in {os.getcwd()}. No check-in performed.')
|
|
106
|
+
return False
|
|
107
|
+
fullfilename=os.path.join(self.root,filename)
|
|
108
|
+
if os.path.exists(fullfilename):
|
|
109
|
+
if overwrite:
|
|
110
|
+
shutil.copyfile(basefilename,fullfilename)
|
|
111
|
+
else:
|
|
112
|
+
logger.debug(f'{filename} already exists in system library. No check-in performed.')
|
|
113
|
+
else:
|
|
114
|
+
shutil.copyfile(basefilename,fullfilename)
|
|
115
|
+
return True
|
|
116
|
+
|
|
117
|
+
def checkout(self,filename,searchpath=[],altpath=[]):
|
|
118
|
+
"""checkout check the file named by filename out of this RuntimeLibrary and copy it to the cwd
|
|
119
|
+
|
|
120
|
+
:param filename: name of file to checkout, relative to the top level directory in which the library is found
|
|
121
|
+
:type filename: str
|
|
122
|
+
:param searchpath: path of directories to search if the filename is not resolved, defaults to []
|
|
123
|
+
:type searchpath: list, optional
|
|
124
|
+
:param altpath: additional directories to add to the search path, defaults to []
|
|
125
|
+
:type altpath: list, optional
|
|
126
|
+
:return: True if file checkout was successful, False if not
|
|
127
|
+
:rtype: bool
|
|
128
|
+
"""
|
|
129
|
+
basefilename=os.path.basename(filename)
|
|
130
|
+
fullfilename=os.path.join(self.root,filename)
|
|
131
|
+
if os.path.exists(fullfilename):
|
|
132
|
+
shutil.copyfile(fullfilename,os.path.join(os.getcwd(),basefilename))
|
|
133
|
+
return True
|
|
134
|
+
else:
|
|
135
|
+
# logger.info(f'No {filename} found in libraries; checking local data searchpath {searchpath}')
|
|
136
|
+
if altpath:
|
|
137
|
+
searchpath.append(altpath)
|
|
138
|
+
# logger.info(f'and alternative path {altpath}')
|
|
139
|
+
for p in searchpath:
|
|
140
|
+
# logger.debug(f'Searching {p}...')
|
|
141
|
+
fullfilename=os.path.join(p,filename)
|
|
142
|
+
if os.path.exists(fullfilename):
|
|
143
|
+
basefilename=os.path.basename(filename)
|
|
144
|
+
shutil.copyfile(fullfilename,basefilename)
|
|
145
|
+
return True
|
|
146
|
+
# logger.debug(f'Could not find {filename} anywhere in user library!')
|
|
147
|
+
return False
|
|
148
|
+
|
|
149
|
+
def exists(self,filename):
|
|
150
|
+
"""exists checks to see if filename exists in this RuntimeLibrary
|
|
151
|
+
|
|
152
|
+
:param filename: name of file to check for, relative to toplevel directory of RuntimeLibrary
|
|
153
|
+
:type filename: str
|
|
154
|
+
:return: True if filename exists in RuntimeLibrary, False otherwise
|
|
155
|
+
:rtype: bool
|
|
156
|
+
"""
|
|
157
|
+
fullfilename=os.path.join(self.root,filename)
|
|
158
|
+
return os.path.exists(fullfilename)
|
|
159
|
+
|
|
160
|
+
def info(self):
|
|
161
|
+
"""info returns a simple string describing this RuntimeLibrary
|
|
162
|
+
|
|
163
|
+
:return: the string
|
|
164
|
+
:rtype: str
|
|
165
|
+
"""
|
|
166
|
+
return f'{self.designation} library is {self.root}'
|
|
167
|
+
|
|
168
|
+
_SYSTEM_LIBRARY_=None
|
|
169
|
+
def lib_setup():
|
|
170
|
+
"""lib_setup sets up the system RuntimeLibrary
|
|
171
|
+
|
|
172
|
+
:return: system RuntimeLibrary object
|
|
173
|
+
:rtype: RuntimeLibrary
|
|
174
|
+
"""
|
|
175
|
+
global _SYSTEM_LIBRARY_
|
|
176
|
+
if _SYSTEM_LIBRARY_==None:
|
|
177
|
+
_SYSTEM_LIBRARY_=RuntimeLibrary.system()
|
|
178
|
+
return _SYSTEM_LIBRARY_
|
|
179
|
+
def system():
|
|
180
|
+
"""system returns the system RuntimeLibrary object
|
|
181
|
+
|
|
182
|
+
:return: system RuntimeLibrary object
|
|
183
|
+
:rtype: RuntimeLibrary
|
|
184
|
+
"""
|
|
185
|
+
return _SYSTEM_LIBRARY_
|
|
186
|
+
|
|
187
|
+
class ProjectFileSystem:
|
|
188
|
+
""" Handles all aspects of the creation and organization of a project filesystem
|
|
189
|
+
"""
|
|
190
|
+
def __init__(self,root='.',topdirs=['molecules','systems','plots'],projdir='next',verbose=False,reProject=False,userlibrary=None,mock=False):
|
|
191
|
+
"""__init__ Generates a new ProjectFilesystem object
|
|
192
|
+
|
|
193
|
+
:param root: path of root directory in which the project directory is to be housed, defaults to '.'
|
|
194
|
+
:type root: str, optional
|
|
195
|
+
:param topdirs: names of toplevel directories in the project directory, defaults to ['molecules','systems','plots']
|
|
196
|
+
:type topdirs: list, optional
|
|
197
|
+
:param projdir: name of the project directory, or 'next' if next available automatically generated name is to be used, defaults to 'next'
|
|
198
|
+
:type projdir: str, optional
|
|
199
|
+
:param verbose: flag to turn on verbose output, defaults to False
|
|
200
|
+
:type verbose: bool, optional
|
|
201
|
+
:param reProject: flag indicating if this is a restarted project, defaults to False
|
|
202
|
+
:type reProject: bool, optional
|
|
203
|
+
:param userlibrary: name of user library toplevel directory, relative to root, defaults to None
|
|
204
|
+
:type userlibrary: str, optional
|
|
205
|
+
:param mock: flag indicating if this is a mock call, defaults to False
|
|
206
|
+
:type mock: bool, optional
|
|
207
|
+
"""
|
|
208
|
+
self.library=lib_setup()
|
|
209
|
+
self.userlibrary=None
|
|
210
|
+
if userlibrary:
|
|
211
|
+
self.userlibrary=RuntimeLibrary.user(userlibrary)
|
|
212
|
+
self.rootPath=os.path.abspath(root)
|
|
213
|
+
os.chdir(self.rootPath)
|
|
214
|
+
self.cwd=self.rootPath
|
|
215
|
+
self.verbose=verbose
|
|
216
|
+
if not mock:
|
|
217
|
+
self._next_project_dir(projdir=projdir,reProject=reProject)
|
|
218
|
+
self._setup_project_dir(topdirs=topdirs)
|
|
219
|
+
|
|
220
|
+
def cdroot(self):
|
|
221
|
+
"""cdroot change the cwd to the root (parent directory of project directory)
|
|
222
|
+
"""
|
|
223
|
+
os.chdir(self.rootPath)
|
|
224
|
+
self.cwd=self.rootPath
|
|
225
|
+
|
|
226
|
+
def cdproj(self):
|
|
227
|
+
"""cdproj change the cwd to the toplevel project directory
|
|
228
|
+
"""
|
|
229
|
+
os.chdir(self.projPath)
|
|
230
|
+
self.cwd=self.projPath
|
|
231
|
+
|
|
232
|
+
def go_to(self,subPath,make=False):
|
|
233
|
+
"""go_to change the cwd to the directory named by 'subPath'
|
|
234
|
+
|
|
235
|
+
:param subPath: directory to change to, relative to project directory
|
|
236
|
+
:type subPath: str
|
|
237
|
+
"""
|
|
238
|
+
self.cdproj()
|
|
239
|
+
if os.path.exists(subPath):
|
|
240
|
+
os.chdir(subPath)
|
|
241
|
+
self.cwd=os.getcwd()
|
|
242
|
+
elif make:
|
|
243
|
+
os.mkdir(subPath)
|
|
244
|
+
os.chdir(subPath)
|
|
245
|
+
self.cwd=os.getcwd()
|
|
246
|
+
|
|
247
|
+
def __str__(self):
|
|
248
|
+
return f'root {self.rootPath}: cwd {self.cwd}'
|
|
249
|
+
|
|
250
|
+
def _next_project_dir(self,projdir='next',reProject=False,prefix='proj-'):
|
|
251
|
+
"""_next_project_dir sets the name of the current project directory and creates it if necessary
|
|
252
|
+
|
|
253
|
+
:param projdir: name of next project directory, defaults to 'next'
|
|
254
|
+
:type projdir: str, optional
|
|
255
|
+
:param reProject: flag indicating if this is a restart, defaults to False
|
|
256
|
+
:type reProject: bool, optional
|
|
257
|
+
:param prefix: prefix for automatically generated project directories, defaults to 'proj-'
|
|
258
|
+
:type prefix: str, optional
|
|
259
|
+
"""
|
|
260
|
+
if not projdir=='next': # explicit project directory is named
|
|
261
|
+
# if os.path.exists(projdir) and not reProject:
|
|
262
|
+
# raise Exception(f'Project directory {projdir} exists but you did not indicate you wanted to restart with the "-restart" flag')
|
|
263
|
+
self.projPath=os.path.join(self.rootPath,projdir)
|
|
264
|
+
if os.path.exists(projdir):
|
|
265
|
+
logger.info(f'Working in existing project {self.projPath}')
|
|
266
|
+
else:
|
|
267
|
+
os.mkdir(projdir)
|
|
268
|
+
logger.info(f'Working in new project {self.projPath}')
|
|
269
|
+
else:
|
|
270
|
+
i=0
|
|
271
|
+
lastprojdir=''
|
|
272
|
+
currentprojdir=''
|
|
273
|
+
while(os.path.isdir(os.path.join(self.rootPath,f'{prefix}{i}'))):
|
|
274
|
+
lastprojdir=f'{prefix}{i}'
|
|
275
|
+
logger.debug(f'{lastprojdir} exists')
|
|
276
|
+
i+=1
|
|
277
|
+
assert not os.path.exists(f'{prefix}{i}')
|
|
278
|
+
if not reProject or lastprojdir=='': # this is a fresh project
|
|
279
|
+
if lastprojdir=='':
|
|
280
|
+
currentprojdir=f'{prefix}0'
|
|
281
|
+
else:
|
|
282
|
+
currentprojdir=f'{prefix}{i}'
|
|
283
|
+
self.projPath=os.path.join(self.rootPath,currentprojdir)
|
|
284
|
+
logger.info(f'New project in {self.projPath}')
|
|
285
|
+
os.mkdir(currentprojdir)
|
|
286
|
+
else:
|
|
287
|
+
self.projPath=os.path.join(self.rootPath,lastprojdir)
|
|
288
|
+
logger.info(f'Restarting project in {self.projPath} (latest project)')
|
|
289
|
+
|
|
290
|
+
def _setup_project_dir(self,topdirs=['molecules','systems','plots']):
|
|
291
|
+
"""_setup_project_dir sets up the project directory after it is created by creating the requested top-level subdirectories
|
|
292
|
+
|
|
293
|
+
:param topdirs: top-level subdirectories, defaults to ['molecules','systems','plots']
|
|
294
|
+
:type topdirs: list, optional
|
|
295
|
+
"""
|
|
296
|
+
os.chdir(self.projPath)
|
|
297
|
+
self.projSubPaths={}
|
|
298
|
+
for tops in topdirs:
|
|
299
|
+
self.projSubPaths[tops]=os.path.join(self.projPath,tops)
|
|
300
|
+
if not os.path.isdir(self.projSubPaths[tops]):
|
|
301
|
+
os.mkdir(tops)
|
|
302
|
+
|
|
303
|
+
_PFS_:ProjectFileSystem=None
|
|
304
|
+
|
|
305
|
+
def pfs_setup(root='.',topdirs=['molecules','systems','plots'],projdir='next',
|
|
306
|
+
verbose=False,reProject=False,userlibrary=None,mock=False):
|
|
307
|
+
"""pfs_setup sets up the global ProjectFileSystem object
|
|
308
|
+
|
|
309
|
+
:param root: parent directory of this project file system, defaults to '.'
|
|
310
|
+
:type root: str, optional
|
|
311
|
+
:param topdirs: top-level subdirectories, defaults to ['molecules','systems','plots']
|
|
312
|
+
:type topdirs: list, optional
|
|
313
|
+
:param projdir: name of the project directory itself, defaults to 'next'
|
|
314
|
+
:type projdir: str, optional
|
|
315
|
+
:param verbose: flag indicating verbose output, defaults to False
|
|
316
|
+
:type verbose: bool, optional
|
|
317
|
+
:param reProject: flag indicating restart, defaults to False
|
|
318
|
+
:type reProject: bool, optional
|
|
319
|
+
:param userlibrary: name of user library relative to root, defaults to None
|
|
320
|
+
:type userlibrary: str, optional
|
|
321
|
+
:param mock: flag indicating this is a mock call, defaults to False
|
|
322
|
+
:type mock: bool, optional
|
|
323
|
+
"""
|
|
324
|
+
global _PFS_
|
|
325
|
+
_PFS_=ProjectFileSystem(root=root,topdirs=topdirs,projdir=projdir,verbose=verbose,reProject=reProject,userlibrary=userlibrary,mock=mock)
|
|
326
|
+
|
|
327
|
+
def checkout(filename,altpath=[]):
|
|
328
|
+
"""checkout handles checking files out of the library owned by the global ProjectFileSystem object; tries to checkout from user-level local library first before trying to check out from the global system Library subpackage
|
|
329
|
+
|
|
330
|
+
:param filename: name of file to check out relative to top-level of library
|
|
331
|
+
:type filename: str
|
|
332
|
+
:param altpath: list of alternate directories to search, defaults to []
|
|
333
|
+
:type altpath: list, optional
|
|
334
|
+
:return: True if checkout from user library successful, otherwise returns result of checkout from global system Library (also a bool)
|
|
335
|
+
:rtype: bool
|
|
336
|
+
"""
|
|
337
|
+
if _PFS_.userlibrary and _PFS_.userlibrary.checkout(filename,searchpath=[_PFS_.rootPath,_PFS_.projPath],altpath=altpath):
|
|
338
|
+
return True
|
|
339
|
+
return _PFS_.library.checkout(filename)
|
|
340
|
+
|
|
341
|
+
def fetch_molecule_files(mname):
|
|
342
|
+
"""fetch_molecule_files fetches all relevant molecule data files for molecule named 'mname'
|
|
343
|
+
|
|
344
|
+
:param mname: name of molecule
|
|
345
|
+
:type mname: str
|
|
346
|
+
:return: list of filetypes found and fetched
|
|
347
|
+
:rtype: list
|
|
348
|
+
"""
|
|
349
|
+
ret_exts=[]
|
|
350
|
+
dirname='molecules/parameterized'
|
|
351
|
+
for e in ['mol2','pdb','gro','top','itp','grx']:
|
|
352
|
+
prob_filename=os.path.join(dirname,f'{mname}.{e}')
|
|
353
|
+
if exists(prob_filename):
|
|
354
|
+
ret_exts.append(e)
|
|
355
|
+
checkout(prob_filename)
|
|
356
|
+
return ret_exts
|
|
357
|
+
|
|
358
|
+
def exists(filename):
|
|
359
|
+
"""exists checks for existence of filename in user-level local library, then in the system Library
|
|
360
|
+
|
|
361
|
+
:param filename: name of file
|
|
362
|
+
:type filename: str
|
|
363
|
+
:return: True if found in either library
|
|
364
|
+
:rtype: bool
|
|
365
|
+
"""
|
|
366
|
+
# check user library first
|
|
367
|
+
if _PFS_.userlibrary and _PFS_.userlibrary.exists(filename):
|
|
368
|
+
return True
|
|
369
|
+
# check system library
|
|
370
|
+
return _PFS_.library.exists(filename)
|
|
371
|
+
|
|
372
|
+
def checkin(filename,overwrite=False,priority='user'):
|
|
373
|
+
"""checkin check the file named 'filename' into either the user-level local library or the global system Library package (the latter requires write priveleges wherever Python packages are stored if HTPolyNet is installed without -e or from PyPI)
|
|
374
|
+
|
|
375
|
+
:param filename: name of file to check in
|
|
376
|
+
:type filename: str
|
|
377
|
+
:param overwrite: flag indicates whether file should overwrite file of same name in library, defaults to False
|
|
378
|
+
:type overwrite: bool, optional
|
|
379
|
+
:param priority: string indicating which library to check into, defaults to 'user'
|
|
380
|
+
:type priority: str, optional
|
|
381
|
+
"""
|
|
382
|
+
if _PFS_.userlibrary and priority=='user':
|
|
383
|
+
_PFS_.userlibrary.checkin(filename,overwrite=overwrite)
|
|
384
|
+
else:
|
|
385
|
+
_PFS_.library.checkin(filename,overwrite=overwrite)
|
|
386
|
+
|
|
387
|
+
def subpath(name):
|
|
388
|
+
"""subpath returns the path of the project subdirectory with name 'name'
|
|
389
|
+
|
|
390
|
+
:param name: name of subdirectory
|
|
391
|
+
:type name: str
|
|
392
|
+
:return: path of subdirectory
|
|
393
|
+
:rtype: os.path
|
|
394
|
+
"""
|
|
395
|
+
return _PFS_.projSubPaths[name]
|
|
396
|
+
|
|
397
|
+
def go_proj():
|
|
398
|
+
"""go_proj change the current working directory to the project directory
|
|
399
|
+
"""
|
|
400
|
+
_PFS_.cdproj()
|
|
401
|
+
|
|
402
|
+
def go_root():
|
|
403
|
+
"""go_root change the current working directory to the root directory
|
|
404
|
+
"""
|
|
405
|
+
_PFS_.cdroot()
|
|
406
|
+
|
|
407
|
+
def go_to(pathstr):
|
|
408
|
+
"""go_to Change the current working directory to "pathstr" which is relative to the project root.
|
|
409
|
+
|
|
410
|
+
:param pathstr: pathname of directory relative to project root
|
|
411
|
+
:type pathstr: str
|
|
412
|
+
:return: absolute path of current working direcory
|
|
413
|
+
:rtype: os.path
|
|
414
|
+
"""
|
|
415
|
+
_PFS_.cdproj()
|
|
416
|
+
dirname=os.path.dirname(pathstr)
|
|
417
|
+
if dirname=='':
|
|
418
|
+
dirname=pathstr # assume this is a topdir
|
|
419
|
+
assert dirname in _PFS_.projSubPaths,f'Error: cannot navigate using pathstring {pathstr}'
|
|
420
|
+
reentry=True
|
|
421
|
+
if not os.path.exists(dirname):
|
|
422
|
+
os.mkdir(dirname)
|
|
423
|
+
reentry=False
|
|
424
|
+
os.chdir(dirname)
|
|
425
|
+
basename=os.path.basename(pathstr)
|
|
426
|
+
if basename!=pathstr: # this is not a topdir
|
|
427
|
+
if not os.path.exists(basename):
|
|
428
|
+
logger.debug(f'PFS: making {basename}')
|
|
429
|
+
os.mkdir(basename)
|
|
430
|
+
os.chdir(basename)
|
|
431
|
+
_PFS_.cwd=os.getcwd()
|
|
432
|
+
return reentry
|
|
433
|
+
|
|
434
|
+
def root():
|
|
435
|
+
"""root returns name of root directory (parent of project directory)
|
|
436
|
+
|
|
437
|
+
:return: name of root directory
|
|
438
|
+
:rtype: os.path
|
|
439
|
+
"""
|
|
440
|
+
return _PFS_.rootPath
|
|
441
|
+
|
|
442
|
+
def cwd():
|
|
443
|
+
"""cwd returns name of current working directory relative to the root path
|
|
444
|
+
|
|
445
|
+
:return: name of current working directory relative to the root path
|
|
446
|
+
:rtype: os.path
|
|
447
|
+
"""
|
|
448
|
+
return os.path.relpath(os.getcwd(),start=_PFS_.rootPath)
|
|
449
|
+
|
|
450
|
+
def proj():
|
|
451
|
+
"""proj returns name of project directory
|
|
452
|
+
|
|
453
|
+
:return: name of project directory
|
|
454
|
+
:rtype: os.path
|
|
455
|
+
"""
|
|
456
|
+
return _PFS_.projPath
|
|
457
|
+
|
|
458
|
+
def local_data_searchpath():
|
|
459
|
+
"""local_data_searchpath returns container containing root path and project path
|
|
460
|
+
|
|
461
|
+
:return: list containing root path and project path
|
|
462
|
+
:rtype: list
|
|
463
|
+
"""
|
|
464
|
+
return [_PFS_.rootPath,_PFS_.projPath]
|
|
465
|
+
|
|
466
|
+
def info():
|
|
467
|
+
"""info prints some summary information about Libraries to the console
|
|
468
|
+
"""
|
|
469
|
+
if _PFS_.userlibrary:
|
|
470
|
+
print(_PFS_.userlibrary.info())
|
|
471
|
+
print(_PFS_.library.info())
|
|
472
|
+
|
|
473
|
+
def proj_abspath(filename):
|
|
474
|
+
"""proj_abspath returns the path of the file named filename relative to the project directory
|
|
475
|
+
|
|
476
|
+
:param filename: name of the probe file
|
|
477
|
+
:type filename: str
|
|
478
|
+
:return: name of probe file relative to the project directory
|
|
479
|
+
:rtype: os.path
|
|
480
|
+
"""
|
|
481
|
+
abf=os.path.abspath(filename)
|
|
482
|
+
return os.path.relpath(abf,_PFS_.projPath)
|
|
483
|
+
|