Skip to content

Commit

Permalink
created a chiralyty script
Browse files Browse the repository at this point in the history
gsym tsym -> gsym
install.rst updated to the new cosymlib module
  • Loading branch information
efrembernuz committed Dec 22, 2020
1 parent 13b0a35 commit 3141380
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,17 @@ for python3 ::
the code will be installed as a python module. To check that it is properly installed you can
run the :program:`python` interpret and execute ::

import symeess
import cosymlib

Install via pip
_______________

If pip is already installed in your computer, you can download and install the cosymlib module as any other
module in python ::

pip install cosymlib --user

for python3 ::

pip3 install cosymlib --user

108 changes: 108 additions & 0 deletions scripts/chirality
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/env python
from cosymlib import Cosymlib, __version__
from cosymlib.file_io.tools import print_header, print_footer, print_input_info
from cosymlib.file_io import read_generic_structure_file
import argparse
import sys
import yaml


# positional arguments
parser = argparse.ArgumentParser(description='gsym')

# positional arguments
parser.add_argument(type=str,
dest='input_file',
nargs='?', default=None,
help='input file with structures')
parser.add_argument(type=str,
dest="yaml_input",
nargs='?', default=None,
help='input file with keywords')
# Main options
parser.add_argument('-m', '--measure',
dest='measure',
metavar='SG',
default=False,
help='compute the SG symmetry measure of the input structures')
parser.add_argument('-o', '--output',
dest='output_name',
metavar='filename',
default=None,
help='store output into a file')
parser.add_argument('-c', '--central_atom',
action='store',
dest='central_atom',
metavar='N',
type=int,
default=0,
help='central atom is in position N in the input structure')

# Extra options
parser.add_argument('--info',
action='store_true',
default=False,
help='print information about the input structures')
parser.add_argument('-v', '--version',
dest='version',
action='store_true',
default=False,
help='print information about the input structures')

# Modifiers
parser.add_argument('--center',
dest='center', metavar='R',
type=float,
default=None,
nargs=3,
help='fix coordinates x,y,z for the center of symmetry operations (Angs)')

args = parser.parse_args()

if args.yaml_input:
with open(args.yaml_input, 'r') as stream:
input_parameters = yaml.load(stream, Loader=yaml.FullLoader)

for key, value in input_parameters.items():
if key.lower() in args:
setattr(args, key.lower(), value)
else:
raise KeyError("Key %s is not valid" % key)

if args.version:
print('Cosymlib version = {}'.format(__version__))
exit()

common_output = open(args.output_name, 'w') if args.output_name is not None else sys.stdout
print_header(common_output)

try:
structures = read_generic_structure_file(args.input_file, read_multiple=True)
except Exception as e:
sys.exit('No input file selected! An existing file must be provide')


structure_set = Cosymlib(structures)

if args.info:
print_input_info(structure_set.get_geometries(), output=common_output)
exit()

# if not args.measure:
# reference = ['ci', 'cs']
# elif args.measure not in ['ci', 'cs']:
# reference = ['ci', 'cs', args.measure]
# else:
# reference = args.measure
if not args.measure:
sys.exit('User should provide a symmetry group measure')
reference = args.measure.lower()

# Symgroup commands
if args.measure:
structure_set.print_geometric_symmetry_measure(reference,
central_atom=args.central_atom,
center=args.center,
output=common_output)

print_footer(common_output)
2 changes: 1 addition & 1 deletion scripts/gsym
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sys
import yaml


parser = argparse.ArgumentParser(description='tsym')
parser = argparse.ArgumentParser(description='gsym')

# positional arguments
parser.add_argument(type=str,
Expand Down

0 comments on commit 3141380

Please sign in to comment.