瀏覽代碼

Fix some references, and improve processing of refs.bib

Ryan C. Thompson 5 年之前
父節點
當前提交
b31f1b0ed7
共有 4 個文件被更改,包括 451 次插入472 次删除
  1. 26 6
      Snakefile
  2. 4 3
      code-refs.bib
  3. 414 456
      refs.bib
  4. 7 7
      thesis.lyx

+ 26 - 6
Snakefile

@@ -5,12 +5,14 @@ import os.path
 import regex
 import urllib.parse
 import os.path
+import bibtexparser
 
 from collections.abc import Iterable, Mapping
 from distutils.spawn import find_executable
 from fnmatch import fnmatch
 from subprocess import check_output, check_call
 from tempfile import NamedTemporaryFile
+from bibtexparser.bibdatabase import BibDatabase
 
 try:
     from os import scandir, walk
@@ -231,15 +233,33 @@ rule lyx_to_pdf_final:
 rule process_bib:
     '''Preprocess bib file for LaTeX.
 
-Currently, this just filters out additional URLs. from the url field,
-since the BibTeX setup in LyX can't handle them.'''
+For entries with a DOI, all URLs are stripped, since the DOI already
+provides a clickable link. For entries with no DOI, all but one URL is
+discarded, since LyX can't handle entries with multiple URLs. The
+shortest URL is kept.'''
     input: '{basename}.bib'
     output: '{basename,.*(?<!-PROCESSED)}-PROCESSED.bib'
     run:
-        with open(input[0]) as infile, open(output[0], 'w') as outfile:
-            for line in infile:
-                line = regex.sub('url = {(.*?) .*},', 'url = {\\1},', line)
-                outfile.write(line)
+        with open(input[0]) as infile:
+            bib_db = bibtexparser.load(infile)
+        entries = bib_db.entries
+        for entry in entries:
+            if 'doi' in entry:
+                try:
+                    del entry['url']
+                except KeyError:
+                    pass
+            else:
+                try:
+                    entry_urls = regex.split('\\s+', entry['url'])
+                    shortest_url = min(entry_urls, key=len)
+                    entry['url'] = shortest_url
+                except KeyError:
+                    pass
+        new_db = BibDatabase()
+        new_db.entries = entries
+        with open(output[0], 'w') as outfile:
+            bibtexparser.dump(new_db, outfile)
 
 rule pdf_extract_page:
     '''Extract a single page from a multi-page PDF.'''

+ 4 - 3
code-refs.bib

@@ -1,7 +1,7 @@
 %% This BibTeX bibliography file was created using BibDesk.
 %% http://bibdesk.sourceforge.net/
 
-%% Created for Ryan C. Thompson at 2019-10-02 00:31:58 -0700 
+%% Created for Ryan C. Thompson at 2019-10-08 22:10:03 -0700 
 
 
 %% Saved with string encoding Unicode (UTF-8) 
@@ -80,13 +80,14 @@ shoal can increase quantification accuracy, inter-sample consistency, and reduce
 	Title = {Reproducible reanalysis of a combined ChIP-Seq \& RNA-Seq data set},
 	Year = {2018}}
 
-@manual{greylistchip,
+@manual{bioc-greylistchip,
 	Author = {Gord Brown},
 	Date-Added = {2019-08-01 02:00:09 -0700},
-	Date-Modified = {2019-08-01 02:03:29 -0700},
+	Date-Modified = {2019-10-08 22:09:47 -0700},
 	Edition = {R package version 1.16.0.},
 	Organization = {Bioconductor},
 	Title = {GreyListChIP: Grey Lists -- Mask Artefact Regions Based on ChIP Inputs},
+	Url = {https://bioconductor.org/packages/release/bioc/html/GreyListChIP.html},
 	Year = {2019}}
 
 @misc{gh-epic,

File diff suppressed because it is too large
+ 414 - 456
refs.bib


+ 7 - 7
thesis.lyx

@@ -1578,7 +1578,7 @@ limma
  expression 
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Law2013"
+key "Law2014"
 literal "false"
 
 \end_inset
@@ -4305,7 +4305,7 @@ voomWithQualityWeights
  
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Law2013,Liu2015"
+key "Law2014,Liu2015"
 literal "false"
 
 \end_inset
@@ -4339,7 +4339,7 @@ limma
 -test 
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Smyth2005,Law2013,Phipson2013"
+key "Smyth2005,Law2014,Phipson2016"
 literal "false"
 
 \end_inset
@@ -8315,7 +8315,7 @@ This table shows both the number of differentially modified promoters detected
  
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Phipson2013"
+key "Phipson2016"
 literal "false"
 
 \end_inset
@@ -12060,7 +12060,7 @@ RNA-seq
  weights to each observation 
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Law2013"
+key "Law2014"
 literal "false"
 
 \end_inset
@@ -13137,7 +13137,7 @@ literal "false"
 ; voom: Use mean-variance trend to assign individual sample weights 
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Law2013"
+key "Law2014"
 literal "false"
 
 \end_inset
@@ -13284,7 +13284,7 @@ literal "false"
  observation weights 
 \begin_inset CommandInset citation
 LatexCommand cite
-key "Law2013"
+key "Law2014"
 literal "false"
 
 \end_inset

Some files were not shown because too many files changed in this diff