Esempio n. 1
0
    def test_snl(self):
        self.trans.set_parameter("author", "will")
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            snl = self.trans.to_snl([("will", "*****@*****.**")])
            self.assertEqual(len(w), 1, "Warning not raised on type conversion " "with other_parameters")
        ts = TransformedStructure.from_snl(snl)
        self.assertEqual(ts.history[-1]["@class"], "SubstitutionTransformation")

        h = ("testname", "testURL", {"test": "testing"})
        snl = StructureNL(ts.final_structure, [("will", "*****@*****.**")], history=[h])
        snl = TransformedStructure.from_snl(snl).to_snl([("notwill", "*****@*****.**")])
        self.assertEqual(snl.history, [h])
        self.assertEqual(snl.authors, [("notwill", "*****@*****.**")])
    def run_task(self, fw_spec):
        db = SPStructuresMongoAdapter.auto_load()
        tstructs = []
        species = fw_spec['species']
        t = fw_spec['threshold']
        for p in SubstitutionPredictor(threshold=t).list_prediction(species):
            subs = p['substitutions']
            if len(set(subs.values())) < len(species):
                continue
            st = SubstitutionTransformation(subs)
            target = map(str, subs.keys())
            for snl in db.get_snls(target):
                ts = TransformedStructure.from_snl(snl)
                ts.append_transformation(st)
                if ts.final_structure.charge == 0:
                    tstructs.append(ts)

        transmuter = StandardTransmuter(tstructs)
        f = RemoveDuplicatesFilter(structure_matcher=StructureMatcher(
            comparator=ElementComparator(), primitive_cell=False))
        transmuter.apply_filter(f)
        results = []
        for ts in transmuter.transformed_structures:
            results.append(ts.to_snl([]).to_dict)
        submissions = SPSubmissionsMongoAdapter.auto_load()
        submissions.insert_results(fw_spec['submission_id'], results)
Esempio n. 3
0
 def test_snl(self):
     self.trans.set_parameter('author', 'will')
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         snl = self.trans.to_snl([('will', '*****@*****.**')])
         self.assertEqual(len(w), 1, 'Warning not raised on type conversion '
                          'with other_parameters')
     ts = TransformedStructure.from_snl(snl)
     self.assertEqual(ts.history[-1]['@class'], 'SubstitutionTransformation')
     
     h = ('testname', 'testURL', {'test' : 'testing'})
     snl = StructureNL(ts.final_structure,[('will', '*****@*****.**')], 
                       history = [h])
     snl = TransformedStructure.from_snl(snl).to_snl([('notwill', 
                                                       '*****@*****.**')])
     self.assertEqual(snl.history, [h])
     self.assertEqual(snl.authors, [('notwill', '*****@*****.**')])
Esempio n. 4
0
    def test_snl(self):
        self.trans.set_parameter("author", "will")
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            snl = self.trans.to_snl([("will", "*****@*****.**")])
            self.assertEqual(
                len(w),
                1,
                "Warning not raised on type conversion " "with other_parameters",
            )
        ts = TransformedStructure.from_snl(snl)
        self.assertEqual(ts.history[-1]["@class"], "SubstitutionTransformation")

        h = ("testname", "testURL", {"test": "testing"})
        snl = StructureNL(ts.final_structure, [("will", "*****@*****.**")], history=[h])
        snl = TransformedStructure.from_snl(snl).to_snl([("notwill", "*****@*****.**")])
        self.assertEqual(snl.history, [h])
        self.assertEqual(snl.authors, [("notwill", "*****@*****.**")])