@@ -0,0 +1,1727 @@
+#!/usr/bin/env python3%0A%0A'''convert gninatypes file to xyz file'''%0Aimport struct, sys, argparse%0Afrom functools import partial%0Aimport molgrid%0A%0Anames = molgrid.GninaIndexTyper().get_type_names()%0A%0Adef elem(t):%0A    '''convert type index into element string'''%0A    name = names%5Bt%5D%0A    if 'Hydrogen' in name:%0A        return 'H'%0A    elif 'Carbon' in name:%0A        return 'C'%0A    elif 'Nitrogen' in name:%0A        return 'N'%0A    elif 'Oxygen' in name:%0A        return 'O'%0A    elif 'Sulfur' in name:%0A        return 'S'%0A    elif 'Phosphorus' == name:%0A        return 'P'%0A    elif 'Fluorine' == name:%0A        return 'F'%0A    elif 'Chlorine' == name:%0A        return 'Cl'%0A    elif 'Bromine' == name:%0A        return 'Br'%0A    elif 'Iodine' == name:%0A        return 'I'%0A    elif 'Magnesium' == name:%0A        return 'Mg'%0A    elif 'Manganese' == name:%0A        return 'Mn'%0A    elif 'Zinc' == name:%0A        return 'Zn'%0A    elif 'Calcium' == name:%0A        return 'Ca'%0A    elif 'Iron' == name:%0A        return 'Fe'%0A    elif 'Boron' == name:%0A        return 'B'%0A    else:%0A        return 'X'%0A        %0A%0Aparser = argparse.ArgumentParser()%0Aparser.add_argument('input',type=str,help='gninatypes file')%0Aparser.add_argument('output', default='-',nargs='?',type=argparse.FileType('w'),help='output xyz')%0A%0Aargs = parser.parse_args()%0A%0A%0Astruct_fmt = 'fffi'%0Astruct_len = struct.calcsize(struct_fmt)%0Astruct_unpack = struct.Struct(struct_fmt).unpack_from%0A%0Awith open(args.input,'rb') as tfile:%0A        results = %5Bstruct_unpack(chunk) for chunk in iter(partial(tfile.read, struct_len), b'')%5D%0A%0Aargs.output.write('%25d%5Cn'%25len(results)) # number atoms%0Aargs.output.write(args.input+'%5Cn') #comment%0Afor x,y,z,t in results:%0A    args.output.write('%25s%5Ct%25f%5Ct%25f%5Ct%25f%5Cn'%25(elem(t),x,y,z))%0A%0A

Convert gninatypes to xyz