Skip to content

Commit

Permalink
Tweak metadata and fix pip install
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Feb 15, 2023
1 parent 12e9c57 commit 7c1509e
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 235 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ keywords:
- "Topas"
- "Structure refinement"
- "Profile refinement"
license: "GPL-2.0"
license: "MIT"
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/stefsmeets/topas_tools"
title: topas_tools
version: "1.0.0"
version: "1.0.1"
...
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ project_urls =
Bug Tracker = https://github.com/stefsmeets/topas_tools/issues
Documentation = https://github.com/stefsmeets/topas_tools
url = https://github.com/stefsmeets/topas_tools
version = 1.0.0
version = 1.0.1


[options]
Expand All @@ -52,9 +52,9 @@ console_scripts =
topasrestraints = topas_tools.topas_restraints:main
topas_ndxan = topas_tools.topas_ndxan:main
restraints_statistics = topas_tools.restraints_statistics:main
cif2patterson = topas_tools.cif2patterson
cif2patterson = topas_tools.cif2patterson:main
cif2topas = topas_tools.cif2topas:main
expandcell = topas_tools.expandcell
expandcell = topas_tools.expandcell:main
stripcif = topas_tools.stripcif:main
topasdiff = topas_tools.topasdiff:main
make_superflip = topas_tools.make_superflip:main
Expand Down
114 changes: 56 additions & 58 deletions topas_tools/cif2patterson.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,90 +24,88 @@ def read_cif(f):
val.show_summary().show_scatterers()
return structures

def main():
usage = """cif2patterson structure.cif"""

usage = """cif2patterson structure.cif"""
description = """Notes: Takes any cif file and generated patterson map
"""

description = """Notes: Takes any cif file and generated patterson map
"""
parser = argparse.ArgumentParser( # usage=usage,
description=description,
formatter_class=argparse.RawDescriptionHelpFormatter)

parser = argparse.ArgumentParser( # usage=usage,
description=description,
formatter_class=argparse.RawDescriptionHelpFormatter)

parser.add_argument("args",
type=str, metavar="FILE",
help="Path to input cif")

parser.add_argument("args",
type=str, metavar="FILE",
help="Path to input cif")

parser.set_defaults(
spgr="P1"
)

parser.set_defaults(
spgr="P1"
)
options = parser.parse_args()

options = parser.parse_args()
cif = options.args
s = list(read_cif(cif).values())[0]
s = s.expand_to_p1()
print(f"Expanded to P1 => {s.scatterers().size()} atoms")
print()

cif = options.args
s = list(read_cif(cif).values())[0]
s = s.expand_to_p1()
print(f"Expanded to P1 => {s.scatterers().size()} atoms")
print()
root, ext = os.path.splitext(cif)

root, ext = os.path.splitext(cif)
uc = s.unit_cell()

uc = s.unit_cell()
scatterers = s.scatterers()

scatterers = s.scatterers()
fout1 = open("patterson_dists.txt", 'w')
fout2 = open("patterson_full.txt", 'w')

fout1 = open("patterson_dists.txt", 'w')
fout2 = open("patterson_full.txt", 'w')
distances_all = []

distances_all = []
verbose = False
for atom1 in scatterers:
x1, y1, z1 = atom1.site

verbose = False
for atom1 in scatterers:
x1, y1, z1 = atom1.site

if verbose:
print()
atom1.show()
distances = []
for atom2 in scatterers:
if verbose:
atom2.show()

x2, y2, z2 = atom2.site
print()
atom1.show()
distances = []
for atom2 in scatterers:
if verbose:
atom2.show()

dx, dy, dz = x1-x2, y1-y2, z1-z2
x2, y2, z2 = atom2.site

dx = dx % 1
dy = dy % 1
dz = dz % 1
dx, dy, dz = x1-x2, y1-y2, z1-z2

length = uc.length((dx, dy, dz))
dx = dx % 1
dy = dy % 1
dz = dz % 1

distances.append((atom2.label, dx, dy, dz, length))
length = uc.length((dx, dy, dz))

if verbose:
print(f' --> {atom2.label:>4s} {dx:9.5f} {dy:9.5f} {dz:9.5f} {length:9.5f}')
distances.append((atom2.label, dx, dy, dz, length))

# print atom1.label, '-->', atom2.label, '=', uc.length((dx,dy,dz))
if verbose:
print(f' --> {atom2.label:>4s} {dx:9.5f} {dy:9.5f} {dz:9.5f} {length:9.5f}')

distances_all.extend(distances)
# print atom1.label, '-->', atom2.label, '=', uc.length((dx,dy,dz))

atom1.show(fout2)
for label, dx, dy, dz, distance in sorted(distances, key=lambda x: x[-1]):
print(' --> {:>4s} {:9.5f} {:9.5f} {:9.5f} {:9.5f}'.format(
label, dx, dy, dz, distance), file=fout2)
print(file=fout2)
distances_all.extend(distances)

print('Wrote file', fout2.name)
atom1.show(fout2)
for label, dx, dy, dz, distance in sorted(distances, key=lambda x: x[-1]):
print(' --> {:>4s} {:9.5f} {:9.5f} {:9.5f} {:9.5f}'.format(
label, dx, dy, dz, distance), file=fout2)
print(file=fout2)

for label, dx, dy, dz, distance in sorted(distances_all, key=lambda x: x[-1]):
print(f'{distance:9.5f}', file=fout1)
print('Wrote file', fout2.name)

print('Wrote file', fout1.name)
for label, dx, dy, dz, distance in sorted(distances_all, key=lambda x: x[-1]):
print(f'{distance:9.5f}', file=fout1)

fout1.close()
fout2.close()
print('Wrote file', fout1.name)

sys.exit()
fout1.close()
fout2.close()
Loading

0 comments on commit 7c1509e

Please sign in to comment.