<commit_before>import sys
import math
import json

au2angs = 1.889725989

def main():

    if len(sys.argv) != 3:
        print("Usage: python %s input.json length_units"%(sys.argv[0]))
        print("       where length_units = 'ang' or 'au'")
        sys.exit(0)

    jin = json.load(open(sys.argv[1], 'r'))

    lu = sys.argv[2]
    if lu not in ('ang', 'au'):
        print("wrong units of length")
        sys.exit(0)

    StructureData = DataFactory('structure')

    L = jin["unit_cell"]["lattice_vectors"]

    if lu == 'au':
        for i in range(3):
            for j in range(3):
                L[i][j] /= au2angs

    print("lattice vectors: ", L)

    s = StructureData(cell=L)

    for atom in jin["unit_cell"]["atoms"]:
        for pos in jin["unit_cell"]["atoms"][atom]:
            pos_cart = [0] * 3
            for x in range(3):
                pos_cart[x] = L[0][x] * pos[0] + L[1][x] * pos[1] + L[2][x] * pos[2]
            s.append_atom(position=pos_cart, symbols=atom)

    s.store()

    print "created structure with uuid='{}' and PK={}".format(s.uuid,s.pk)

    return

if __name__ == "__main__":
    main()
<commit_msg>attach imported structures to a predefined group<commit_after>import sys
import math
import json

au2angs = 1.889725989

def main():

    if len(sys.argv) != 3:
        print("Usage: python %s input.json length_units"%(sys.argv[0]))
        print("       where length_units = 'ang' or 'au'")
        sys.exit(0)

    jin = json.load(open(sys.argv[1], 'r'))

    lu = sys.argv[2]
    if lu not in ('ang', 'au'):
        print("wrong units of length")
        sys.exit(0)

    StructureData = DataFactory('structure')

    L = jin["unit_cell"]["lattice_vectors"]

    if lu == 'au':
        for i in range(3):
            for j in range(3):
                L[i][j] /= au2angs

    print("lattice vectors: ", L)

    s = StructureData(cell=L)

    for atom in jin["unit_cell"]["atoms"]:
        for pos in jin["unit_cell"]["atoms"][atom]:
            pos_cart = [0] * 3
            for x in range(3):
                pos_cart[x] = L[0][x] * pos[0] + L[1][x] * pos[1] + L[2][x] * pos[2]
            s.append_atom(position=pos_cart, symbols=atom)

    s.store()

    print "created structure with uuid='{}' and PK={}".format(s.uuid,s.pk)

    grp, created = Group.get_or_create(name='imported_structures')
    grp.add_nodes([s])

    return

if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.1670792079207921, 'fraction_numerical': 0.02392739273927393, 'mean_word_length': 2.3727399165507648, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2456779', 'n_tokens_mistral': 909, 'n_tokens_neox': 867, 'n_words': 210}