From d98e25e0bcae6b83fbc442cfeaaa2a4fe94d0053 Mon Sep 17 00:00:00 2001
From: Berk Onat <b.onat@warwick.ac.uk>
Date: Tue, 10 Apr 2018 16:16:35 +0100
Subject: [PATCH] Adding restricted_uri info

---
 parser/parser-gromos/GROMOSDictionary.py | 45 ++++++++++++++++++++
 parser/parser-gromos/GROMOSParser.py     | 52 +++++++++++++++++++++++-
 2 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/parser/parser-gromos/GROMOSDictionary.py b/parser/parser-gromos/GROMOSDictionary.py
index 569710e..66e1c2d 100644
--- a/parser/parser-gromos/GROMOSDictionary.py
+++ b/parser/parser-gromos/GROMOSDictionary.py
@@ -795,6 +795,49 @@ def get_updateDictionary(self, defname):
             activeSections=['section_energy_van_der_Waals']
             ),
         }
+
+    # Info for section_restricted_uri
+    restrictions = {
+        'number_of_restricted_uri_files' : MetaInfoMap(startpage,
+            value=int(1),
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri']
+            ),
+        'restricted_uri_files' : MetaInfoMap(startpage,
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri'],
+            subfunction={ 
+                'function' : self.parameter_file_name,
+                'supportDict' : self.fileDict,
+                },
+            ),
+        'restricted_uri_license' : MetaInfoMap(startpage,
+            value='GROMOS License',
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri']
+            ),
+        'restricted_uri_restriction' : MetaInfoMap(startpage,
+            value='any access',
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri']
+            ),
+        'restricted_uri_reason' : MetaInfoMap(startpage,
+            value='propriety license',
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri']
+            ),
+        'restricted_uri_issue_authority' : MetaInfoMap(startpage,
+            value='GROMOS',
+            #autoSections=True,
+            activeInfo=True,
+            activeSections=['section_restricted_uri']
+            ),
+        }
    
     # ------------------------------------------
     #   Definitions for section_frame_sequence
@@ -1427,6 +1470,8 @@ def get_updateDictionary(self, defname):
         dictionary = topology
     elif defname == 'singleconfcalc':
         dictionary = singleconfcalc
+    elif defname == 'restrictions':
+        dictionary = restrictions
     elif defname == 'frameseq':
         dictionary = frameseq
     elif defname == 'frameseqend':
diff --git a/parser/parser-gromos/GROMOSParser.py b/parser/parser-gromos/GROMOSParser.py
index f3ab44e..62d5ffc 100644
--- a/parser/parser-gromos/GROMOSParser.py
+++ b/parser/parser-gromos/GROMOSParser.py
@@ -269,8 +269,23 @@ class GROMOSParser(SmartParser.ParserBase):
         #self.initialize_values()
         self.secRunOpen = False
         self.metaStorage.reset({'startSection' : [['section_run']]})
+        self.metaStorageRestrict.reset({'startSection' : [['section_restricted_uri']]})
         self.reset_values()
 
+    def parameter_file_name(self, filedict, itemdict):
+        """ Function to generate data for parameter files list
+        """
+        working_dir_name = os.path.dirname(os.path.normpath(os.path.abspath(self.fName)))
+        parmmeta = isMetaStrInDict("structure",self.fileDict)
+        filename = []
+        if parmmeta is not None:
+            if self.fileDict[parmmeta].value is not None:
+                fname = self.fileDict[parmmeta].value
+                filename.append(fname.replace(working_dir_name, '.'+os.path.sep))
+        if filename:
+            return False, filename, itemdict
+        else:
+            return False, None, itemdict
     def gromos_input_output_files(self, backend, gIndex, section):
         """Called with onClose_x_gromos_section_control_parameters to setup
             topology and trajectory inputs/outputs
@@ -381,7 +396,7 @@ class GROMOSParser(SmartParser.ParserBase):
             trajDone = True
             self.newTraj = True
 
-        #if atLeastOneFileExist:
+        if atLeastOneFileExist:
         #    updateDict = {
         #            'startSection'   : [[PARSERTAG+'_section_input_output_files']],
         #            'dictionary'     : self.fileDict
@@ -390,6 +405,17 @@ class GROMOSParser(SmartParser.ParserBase):
         #    self.metaStorage.updateBackend(backend.superBackend,
         #            startsection=[PARSERTAG+'_section_input_output_files'],
         #            autoopenclose=False)
+            self.secRestrictGIndex = backend.superBackend.openSection("section_restricted_uri")
+            restrictionsDict = get_updateDictionary(self, 'restrictions')
+            updateDict = {
+                    'startSection' : [['section_restricted_uri']],
+                    'dictionary' : restrictionsDict
+                    }
+            self.metaStorageRestrict.update(updateDict)
+            self.metaStorageRestrict.updateBackend(backend.superBackend, 
+                    startsection=['section_restricted_uri'],
+                    autoopenclose=False)
+            backend.superBackend.closeSection("section_restricted_uri", self.secRestrictGIndex)
 
         if self.newTopo:
             if topoDone and atLeastOneFileExist:
@@ -554,6 +580,30 @@ class GROMOSParser(SmartParser.ParserBase):
         #self.stepcontrolDict.update({"follow" : followsteps})
         self.onOpen_section_sampling_method(backend, None, None)
         self.onClose_section_sampling_method(backend, None, None)
+        if self.topology:
+            if self.newTopo:
+                section_file_Dict = {}
+                section_file_Dict.update(self.fileDict)
+                updateDict = {
+                        'startSection' : [[PARSERTAG+'_section_control_parameters']],
+                        'dictionary'   : section_file_Dict
+                        }
+                self.metaStorage.update(updateDict)
+                self.metaStorage.updateBackend(backend.superBackend, 
+                        startsection=[PARSERTAG+'_section_control_parameters'],
+                        autoopenclose=False)
+
+                self.secRestrictGIndex = backend.superBackend.openSection("section_restricted_uri")
+                restrictionsDict = get_updateDictionary(self, 'restrictions')
+                updateDict = {
+                        'startSection' : [['section_restricted_uri']],
+                        'dictionary' : restrictionsDict
+                        }
+                self.metaStorageRestrict.update(updateDict)
+                self.metaStorageRestrict.updateBackend(backend.superBackend, 
+                        startsection=['section_restricted_uri'],
+                        autoopenclose=False)
+                backend.superBackend.closeSection("section_restricted_uri", self.secRestrictGIndex)
 
     def onOpen_section_method(self, backend, gIndex, section):
         # keep track of the latest method section
-- 
GitLab