-
Notifications
You must be signed in to change notification settings - Fork 62
/
provenance.py
82 lines (62 loc) · 2.07 KB
/
provenance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
""" Core definition of a Provenance Document """
from datetime import datetime
from enum import Enum
from typing import ClassVar, Dict, List
from pybtex.database import BibliographyData, parse_string
from pydantic import BaseModel, EmailStr, Field, HttpUrl, validator
from emmet.core.material import PropertyDoc
class Database(Enum):
"""
Database identifiers for provenance IDs
"""
ICSD = "icsd"
PaulingFiles = "pf"
COD = "cod"
class Author(BaseModel):
"""
Author information
"""
name: str = Field(None)
email: EmailStr = Field(None)
class History(BaseModel):
"""
History of the material provenance
"""
name: str
url: HttpUrl
description: Dict = Field(
None, description="Dictionary of exra data for this history node"
)
class Provenance(PropertyDoc):
"""
A provenance property block
"""
property_name: ClassVar[str] = "provenance"
created_at: datetime = Field(
None,
description="creation date for the first structure corresponding to this material",
)
projects: List[str] = Field(
None, description="List of projects this material belongs to"
)
bibtex_string: str = Field(
None, description="Bibtex reference string for this material"
)
remarks: List[str] = Field(
None, description="List of remarks for the provenance of this material"
)
authors: List[Author] = Field(None, description="List of authors for this material")
theoretical: bool = Field(
True, description="If this material has any experimental provenance or not"
)
database_IDs: Dict[Database, List[str]] = Field(
None, description="Database IDs corresponding to this material"
)
history: List[History] = Field(
None,
description="List of history nodes specifying the transformations or orignation of this material",
)
@validator("authors")
def remove_duplicate_authors(cls, authors):
authors_dict = {entry.name.lower(): entry for entry in authors}
return list(authors_dict.items())