Last active
August 29, 2015 14:19
-
-
Save zachcp/7af151690c2338d1a882 to your computer and use it in GitHub Desktop.
use eutils to generate yearly histograms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esearch -db pubmed -query "Journal of natural products [JOUR] has abstract [FILT]" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "J Nat Prod Articles w Abs." --outfile "jnp_abst.png" | |
esearch -db pubmed -query "Journal of natural products [JOUR] " | \ | |
efilter -query "rifamycin" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "J Nat Prod Articles" --outfile "jnp_all.png" | |
esearch -db pubmed -query "CRISPR" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "CRISPR" --outfile "eutilsbar_crispr.png" | |
esearch -db pubmed -query "microbiome" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "Microbiome" --outfile "eutilsbar_microbiome.png" | |
esearch -db pubmed -query "metabolomics" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "Metabolomics" --outfile "eutilsbar_metabolomics.png" | |
esearch -db pubmed -query "rapamycin" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "Rapamycin" --outfile "eutilsbar_rapamycin.png" | |
esearch -db pubmed -query "ebola" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "ebola" --outfile "eutilsbar_ebola.png" | |
esearch -db pubmed -query "tetracycline" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "tetracycline" --outfile "eutilsbar_tetracycline.png" | |
esearch -db pubmed -query "penicillin" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "penicillin" --outfile "eutilsbar_penicillin.png" | |
esearch -db pubmed -query "penicillin" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "penicillin" --outfile "eutilsbar_penicillin.png" | |
esearch -db pubmed -query "tuberculosis" | \ | |
efetch -format docsum | \ | |
xtract -pattern DocumentSummary -element PubDate | \ | |
cut -d " " -f 1 | \ | |
cut -d "-" -f 1 | \ | |
python hist.py --title "tuberculosis" --outfile "eutilsbar_tuberculosis.png" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
import sys | |
from toolz.itertoolz import frequencies | |
import matplotlib.pyplot as plt | |
years = sys.stdin | |
@click.command() | |
@click.option('--title', default = "", help='Histrogram Title') | |
@click.option('--outfile', default = "", help='Histrogram Title') | |
def process(title, outfile): | |
year_freqs = frequencies(years) | |
xvals = [int(key.strip()) for key in year_freqs.keys()] | |
yvals = [v for v in year_freqs.values()] | |
plt.bar(xvals, yvals) | |
plt.xlabel('Year') | |
plt.ylabel('Frequency') | |
plt.title(title) | |
plt.savefig(outfile) | |
if __name__ == "__main__": | |
process() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment