<commit_before>#!/usr/bin/python
import numpy as np
import sys
import copy
import subprocess as sp
import os
import errno
import shutil
import re
import argparse 
import lxml.etree as lxml
import numpy.linalg as lg
import time
from __tools__ import MyParser
from __tools__ import cd
from __tools__ import XmlParser
from __xtpAtom__ import atom
from __xtpMolecule__ import molecule



parser=MyParser(description="Environment to check coupling constants")

parser.add_argument("--template","-t",type=str,required=True,help="Folder, from which to take optionfiles from and where the exciton tool had been executed for one molecule")
parser.add_argument("--xyz",type=str,help="Name of the xyz file for the molecule")
parser.add_argument("--mps",type=str,default="",help="Name of the mps file for the molecule")
parser.add_argument("--option","-o",type=str,required=True,help="Optionfile")
parser.add_argument("--setup", action='store_const', const=1, default=0,help="Setup folders")
parser.add_argument("--exciton", action='store_const', const=1, default=0,help="Run exciton calc")
parser.add_argument("--excpl", action='store_const', const=1, default=0,help="Run exciton coupling")
parser.add_argument("--qmcpl", action='store_const', const=1, default=0,help="Run e/h coupling")
parser.add_argument("--clcpl", action='store_const', const=1, default=0,help="Run classical coupling")

args=parser.parse_args()
if args.mps=="":
    args.mps=None

def readoptionsfile(optionfile):
    print "Reading options from {}".format(optionfile)
    parser=lxml.XMLParser(remove_comments=True)
    tree = lxml.parse(optionfile,parser)
    root = tree.getroot()      
    distances=[]
    rotations=[]
    states=np.array([15])
    for child in root:
        if child.tag=="distances":
            for distance in child:
                temp=np.array((distance.text).split(),dtype=float)
                distances.append(temp)
        if child.tag=="rotations":
            for rotation in child:
                temp=np.array((rotation.text).split(),dtype=float)
                rotations.append(temp)
        if child.tag=="states":
            states=np.array((child.text).split(),dtype=int)
    if len(rotations)==0:
        rotations=[None]
    #print distances,rotations
    return distances,rotations,states

               

class job:
    
    def __init__(self,name,template,shift=None,rotation=None):
        self.name=str(name)
        self.options=None
        temp=""
        if shift!=None:
            temp+="_{:1.2f}_{:1.2f}_{:1.2f}".format(shift[0],shift[1],shift[2])
        if rotation!=None:
            temp+="_r_{:1.1f}_{:1.1f}_{:1.1f}_{:1.2f}".format(rotation[0],rotation[1],rotation[2],rotation[3])
        self.setname(self.name+temp)
        self.template=os.path.abspath(template)
        self.shift=shift
        if rotation!=None:
            if rotation[-1]==0:
                self.rotation=None
            else:
                self.rotation=rotation

    def setname(self,name):
        self.name=name
        self.path=os.path.join(os.getcwd(),name)

    def makefolder(self):
        os.mkdir(self.path)

    def setup(self,xyzfile,mpsfile=None):     
        self.makefolder()
        self.createdimer(xyzfile,mpsfile=mpsfile)  

    def createmonomer(self,infile,outfile):
        mol1=molecule()
        print infile
        mol1.readxyzfile(os.path.join(self.template,infile))
        if self.shift!=None:
            mol1.shift(self.shift)
        if self.rotation!=None:
            mol1.rotate(rotation)
       
        mol1.writexyz(os.path.join(self.path,outfile),header=True)      
		  
 
    def createdimer(self,infile):
        mol1=molecule()
        mol1.readxyzfile(os.path.join(self.template,infile))            
        mol2=mol1.copy()
        if self.shift!=None:<commit_msg>bugfix<commit_after>#!/usr/bin/python
import numpy as np
import sys
import copy
import subprocess as sp
import os
import errno
import shutil
import re
import argparse 
import lxml.etree as lxml
import numpy.linalg as lg
import time
from __tools__ import MyParser
from __tools__ import cd
from __tools__ import XmlParser
from __xtpAtom__ import atom
from __xtpMolecule__ import molecule



parser=MyParser(description="Environment to check coupling constants")

parser.add_argument("--template","-t",type=str,required=True,help="Folder, from which to take optionfiles from and where the exciton tool had been executed for one molecule")
parser.add_argument("--xyz",type=str,help="Name of the xyz file for the molecule")
parser.add_argument("--mps",type=str,default="",help="Name of the mps file for the molecule")
parser.add_argument("--option","-o",type=str,required=True,help="Optionfile")
parser.add_argument("--setup", action='store_const', const=1, default=0,help="Setup folders")
parser.add_argument("--exciton", action='store_const', const=1, default=0,help="Run exciton calc")
parser.add_argument("--excpl", action='store_const', const=1, default=0,help="Run exciton coupling")
parser.add_argument("--qmcpl", action='store_const', const=1, default=0,help="Run e/h coupling")
parser.add_argument("--clcpl", action='store_const', const=1, default=0,help="Run classical coupling")

args=parser.parse_args()
if args.mps=="":
    args.mps=None

def readoptionsfile(optionfile):
    print "Reading options from {}".format(optionfile)
    parser=lxml.XMLParser(remove_comments=True)
    tree = lxml.parse(optionfile,parser)
    root = tree.getroot()      
    distances=[]
    rotations=[]
    states=np.array([15])
    for child in root:
        if child.tag=="distances":
            for distance in child:
                temp=np.array((distance.text).split(),dtype=float)
                distances.append(temp)
        if child.tag=="rotations":
            for rotation in child:
                temp=np.array((rotation.text).split(),dtype=float)
                rotations.append(temp)
        if child.tag=="states":
            states=np.array((child.text).split(),dtype=int)
    if len(rotations)==0:
        rotations=[None]
    #print distances,rotations
    return distances,rotations,states

               

class job:
    
    def __init__(self,name,template,shift=None,rotation=None):
        self.name=str(name)
        self.options=None
        temp=""
        if shift!=None:
            temp+="_{:1.2f}_{:1.2f}_{:1.2f}".format(shift[0],shift[1],shift[2])
        if rotation!=None:
            temp+="_r_{:1.1f}_{:1.1f}_{:1.1f}_{:1.2f}".format(rotation[0],rotation[1],rotation[2],rotation[3])
        self.setname(self.name+temp)
        self.template=os.path.abspath(template)
        self.shift=shift
        if rotation!=None:
            if rotation[-1]==0:
                self.rotation=None
            else:
                self.rotation=rotation

    def setname(self,name):
        self.name=name
        self.path=os.path.join(os.getcwd(),name)

    def makefolder(self):
        os.mkdir(self.path)

    def setup(self,xyzfile,mpsfile=None):     
        self.makefolder()
        self.createdimer(xyzfile)  

    def createmonomer(self,infile,outfile):
        mol1=molecule()
        print infile
        mol1.readxyzfile(os.path.join(self.template,infile))
        if self.shift!=None:
            mol1.shift(self.shift)
        if self.rotation!=None:
            mol1.rotate(rotation)
       
        mol1.writexyz(os.path.join(self.path,outfile),header=True)      
		  
 
    def createdimer(self,infile):
        mol1=molecule()
        mol1.readxyzfile(os.path.join(self.template,infile))            
        mol2=mol1.copy()
        if self.shift!=None:
{'fraction_non_alphanumeric': 0.13671618246352044, 'fraction_numerical': 0.011831208097804654, 'mean_word_length': 3.1733406472846957, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3188978', 'n_tokens_mistral': 2458, 'n_tokens_neox': 2385, 'n_words': 449}