<commit_before>'''
    Script to convert .xsd file to VASP input files.
'''
import commands
import os
import sys

import numpy as np

from vaspy.matstudio import XsdFile

status, output = commands.getstatusoutput('ls *.xsd | head -1')
xsd = XsdFile(filename=output)
poscar_content = xsd.get_poscar_content(bases_const=1.0)
with open('POSCAR', 'w') as f:
    f.write(poscar_content)

#create POTCAR
potdir = r'/data/pot/vasp/potpaw_PBE2010/'
for elem in xsd.atoms:
    if os.path.exists(potdir + elem + '_new/'):
        potcar = potdir + elem + '_new/POTCAR'
    elif os.path.exists(potdir + elem):
        potcar = potdir + elem + '/POTCAR'
    else:
        print 'No POTCAR for ' + elem
        sys.exit(1)
    commands.getstatusoutput('cat ' + potcar + ' >> ./POTCAR')

#creat KPOINTS
kpoints = []
for base in xsd.bases:
    l = np.dot(base, base)**0.5
    kpt = int(20/l) + 1
    kpoints.append(str(kpt))
kpt_str = ' '.join(kpoints)
kpt_content = 'mesh auto\n0\nG\n' + kpt_str + '\n0 0 0\n'
with open('KPOINTS', 'w') as f:
    f.write(kpt_content)

#copy INCAR vasp.script
commands.getstatusoutput('cp $HOME/example/INCAR $HOME/example/vasp.script ./')<commit_msg>add jobname modification<commit_after>'''
    Script to convert .xsd file to VASP input files.
'''
import commands
import os
import sys

import numpy as np

from vaspy.matstudio import XsdFile

#create POSCAR
status, output = commands.getstatusoutput('ls *.xsd | head -1')
xsd = XsdFile(filename=output)
poscar_content = xsd.get_poscar_content(bases_const=1.0)
with open('POSCAR', 'w') as f:
    f.write(poscar_content)

#create POTCAR
potdir = r'/data/pot/vasp/potpaw_PBE2010/'
for elem in xsd.atoms:
    if os.path.exists(potdir + elem + '_new/'):
        potcar = potdir + elem + '_new/POTCAR'
    elif os.path.exists(potdir + elem):
        potcar = potdir + elem + '/POTCAR'
    else:
        print 'No POTCAR for ' + elem
        sys.exit(1)
    commands.getstatusoutput('cat ' + potcar + ' >> ./POTCAR')

#creat KPOINTS
kpoints = []
for base in xsd.bases:
    l = np.dot(base, base)**0.5
    kpt = int(20/l) + 1
    kpoints.append(str(kpt))
kpt_str = ' '.join(kpoints)
kpt_content = 'mesh auto\n0\nG\n' + kpt_str + '\n0 0 0\n'
with open('KPOINTS', 'w') as f:
    f.write(kpt_content)

#copy INCAR vasp.script
commands.getstatusoutput('cp $HOME/example/INCAR $HOME/example/vasp.script ./')
#change jobname
jobname = output.split('.')[0]
with open('vasp.script', 'r') as f:
    content_list = f.readlines()

content_list[1] = '#PBS -N ' + jobname + '\n'
with open('vasp.script', 'w') as f:
    f.writelines(content_list)
{'fraction_non_alphanumeric': 0.15111796453353893, 'fraction_numerical': 0.013878180416345412, 'mean_word_length': 3.4741379310344827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1844962', 'n_tokens_mistral': 1037, 'n_tokens_neox': 998, 'n_words': 242}