From 5923185345449f89281f6d5208e6f09dc29b41b9 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Wed, 12 May 2021 00:14:00 +0200 Subject: tasks: move id extraction to skate-map --- python/refcat/tasks.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/python/refcat/tasks.py b/python/refcat/tasks.py index 868a755..4f7c138 100644 --- a/python/refcat/tasks.py +++ b/python/refcat/tasks.py @@ -342,3 +342,72 @@ class RefsDOI(Refcat): def output(self): return luigi.LocalTarget(path=self.path(ext="tsv.zst"), format=Zstd) + + +class RefsPMID(Refcat): + """ + Sorted (pmid, doc) tuples from refs; PMID is an integer. + """ + def requires(self): + return RefsWithUnstructured() + + def run(self): + output = shellout(""" + zstdcat -T0 {input} | + skate-map -m ff -x biblio.pmid -skip-on-empty 1 | + LC_ALL=C sort -T {tmpdir} -k1,1 -S25% --parallel 4 | + zstd -T0 -c > {output} + """, + n=self.n, + tmpdir=self.tmpdir, + input=self.input().path) + luigi.LocalTarget(output).move(self.output().path) + + def output(self): + return luigi.LocalTarget(path=self.path(ext="tsv.zst"), format=Zstd) + + +class RefsPMCID(Refcat): + """ + Sorted (pmcid, doc) tuples from refs, e.g. PMC2860560, ... + """ + def requires(self): + return RefsWithUnstructured() + + def run(self): + output = shellout(""" + zstdcat -T0 {input} | + skate-map -m ff -x biblio.pmcid -skip-on-empty 1 | + LC_ALL=C sort -T {tmpdir} -k1,1 -S25% --parallel 4 | + zstd -T0 -c > {output} + """, + n=self.n, + tmpdir=self.tmpdir, + input=self.input().path) + luigi.LocalTarget(output).move(self.output().path) + + def output(self): + return luigi.LocalTarget(path=self.path(ext="tsv.zst"), format=Zstd) + + +class RefsArxiv(Refcat): + """ + Sorted (arxiv, doc) tuples from refs, e.g. 1802.3912, ... + """ + def requires(self): + return RefsWithUnstructured() + + def run(self): + output = shellout(""" + zstdcat -T0 {input} | + skate-map -m ff -x biblio.arxiv_id -skip-on-empty 1 | + LC_ALL=C sort -T {tmpdir} -k1,1 -S25% --parallel 4 | + zstd -T0 -c > {output} + """, + n=self.n, + tmpdir=self.tmpdir, + input=self.input().path) + luigi.LocalTarget(output).move(self.output().path) + + def output(self): + return luigi.LocalTarget(path=self.path(ext="tsv.zst"), format=Zstd) -- cgit v1.2.3