-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gsym tsym -> gsym install.rst updated to the new cosymlib module
- Loading branch information
1 parent
13b0a35
commit 3141380
Showing
3 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters