#!/usr/bin/python

# Script for adding gro files (new runs) to a FAH project.
# 
# ============================================================================
# User-specified parts:
projectConfiguration = "/home/server_c/server2/densign/3191/project3191.conf" 
server2dir = "/home/server_c/server"
serverBinary = "serverV3M_c"
SVr = "SVr_c.sh"
grofiles = "newgrofiles"
FAHToolsPath = "/home/server_c/modules/fah_adaptive_sampling/FAHTools"

# Have a file called $grofiles which lists a bunch of gros:
# 
# conf1.gro
# conf2.gro
# conf3.gro
#
# Make sure that a simple open() function can find them (abspath will be
# used, just in case).
# ============================================================================

import sys
sys.path.append( FAHToolsPath )
from FAHProject import FAHProject
from FAHServer import FAHServer
from os.path import abspath

GROLIST = open( grofiles )
grolist = GROLIST.readlines()
GROLIST.close()

project = FAHProject( projectConfiguration, verbose = True )
server = FAHServer( server2dir, serverBinary, SVr, verbose = True )

for gro in grolist :
	gro = abspath( gro.strip() )
	project.addRun( gro )

#project.writeConfig()
#server.runSetupDataDirs()
#server.restartServer()
