Skip to content

Commit

Permalink
protcur document add slug slug rows
Browse files Browse the repository at this point in the history
currently a bit broken
  • Loading branch information
tgbugs committed Jun 27, 2020
1 parent 58a21ea commit 31a653c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
2 changes: 1 addition & 1 deletion protcur/protcur/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.5'
__version__ = '0.0.6'
4 changes: 3 additions & 1 deletion protcur/protcur/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ class protc(AstGeneric):
#TODO we need more here...
))
_manual_fix = {
# FIXME param: vs protc: for fuzzy-quantity, the fuz is not handled
# by the param parser atm so keeping it in protc for now ...
'roomtemperature':('protc:fuzzy-quantity', '"room temperature"', '"temperature"'),
'room temperature':('protc:fuzzy-quantity', '"room temperature"', '"temperature"'),

Expand Down Expand Up @@ -1209,7 +1211,7 @@ def manual_corrections(v):
id, label = self.ontLookup(value)
if id:
#value += f" ({id_}, {data['labels'][0]})"
value = f"(term {id} \"{label}\" #:original \"{value}\"{ont})"
value = f"(term {id} {json.dumps(label)} #:original {json.dumps(value)}{ont})"
#value = ("term", id_, data['labels'][0], "#:original", value)
#raise ValueError(value)
return value
Expand Down
54 changes: 51 additions & 3 deletions protcur/protcur/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,25 +268,73 @@ def _uri_humans(self):
slugs[anno.uri_normalized].append(anno)
return dict(slugs)

def document_rows(self):
def slug_rows(self):
yield ('slug',
'uri',
'anno count',
'doi',
'title',
'author count',
'authors',
'protocol created',
'protocol updated',
'protocol has versions',
'anno date first',
'anno date last',
'anaesthesia',
'microscopy',
'close but no cigar', # euthanasia, ephys rig
)

tails = self.slug_tails()
for slug, pios in self.slug_streams().items():
spios = sorted([p for p in pios], key=lambda p: p.uri_human)
pio = spios[0]
annos = tails[pio.asStr()] # already normalized I think?
hpio = pio.uri_human

minad = min([a.created for a in annos])
maxad = max([a.updated for a in annos])

authors = [a.name for a in hpio.authors]

yield (slug,
hpio.asStr(),
len(annos),
hpio.title, # title
hpio.doi.asStr() if pio.doi else '',
len(authors),
authors_s,
isoformat(hpio.created),
isoformat(hpio.updated),
hpio.hasVersions,
minad,
maxad,
''
'',
'',
'',
)

def document_rows(self):
norms = self.normalized()
yield ('slug',
'uri',
'anno count',
'doi',
'title',
'author count',
'authors',
'protocol created',
'protocol updated',
'protocol has versions',
'anno count',
'anno date first',
'anno date last',
'anaesthesia',
'microscopy',
'close but no cigar', # euthanasia, ephys rig
)

for slug, pios in self.slug_streams().items():
#annos = tails[slug]
spios = sorted([p for p in pios], key=lambda p: p.uri_human)
Expand All @@ -299,14 +347,14 @@ def document_rows(self):
authors_s = '|'.join(authors)
yield (slug,
pio.asStr(),
len(annos),
pio.doi.asStr() if pio.doi else '',
pio.title, # title
len(authors),
authors_s,
isoformat(pio.created),
isoformat(pio.updated),
pio.hasVersions,
len(annos),
minad,
maxad,
''
Expand Down
2 changes: 1 addition & 1 deletion protcur/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def find_version(filename):
install_requires=[
'flask',
'htmlfn',
'hyputils>=0.0.5',
'hyputils>=0.0.6',
'Markdown',
'pyontutils>=0.1.22',
'pysercomb>=0.0.5',
Expand Down

0 comments on commit 31a653c

Please sign in to comment.