<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Code on zachcp</title>
		<link>http://zachcp.org/categories/code/</link>
		<description>Recent content in Code on zachcp</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
			<copyright>© 2007- {year}</copyright>
		
		
			<lastBuildDate>Mon, 30 May 2016 08:03:00 +0000</lastBuildDate>
		
			<atom:link href="http://zachcp.org/categories/code/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Growing Peptides Again</title>
				<link>http://zachcp.org/blog/cdkpeptides-part-ii/</link>
				<pubDate>Mon, 30 May 2016 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/cdkpeptides-part-ii/</guid>
				<description>&lt;pre&gt;&lt;code class=&#34;language-[clojure]&#34;&gt;(peptideanimation &amp;quot;peptidechain.gif&amp;quot; (take 17 aminos) :width 2000 :height 1000)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;img src=&#34;http://zachcp.org/pics/blog/2016/peptidechain.gif&#34; width=800&gt;&#xA;&lt;p&gt;A few small updates to my &lt;a href=&#34;https://github.com/zachcp/drawpeptides&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;peptide viz tool &lt;/a&gt; (described &lt;a href=&#34;http://zachcp.org/blog/2015/clojure-cdk-peptides/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;earlier&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;This GIF simply takes each peptide fragment (1; 1,2; 1,2,3&amp;hellip;), calculates the structure, and concatenates the images to give an effect of the&#xA;peptide growing. Obviously its not perfect, however, you can see that CDK&amp;rsquo;s layout has improved so that the peptide side chains no longer clash.&#xA;You can also note how the longest carbon chain is detected so that sometimes the terminal side-chains are included as part of linear chain,&#xA;causing the chain to &amp;ldquo;bend&amp;rdquo;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Browser Chemistry Part I</title>
				<link>http://zachcp.org/blog/browserchemistry/</link>
				<pubDate>Mon, 08 Jun 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/browserchemistry/</guid>
				<description>&lt;p&gt;A few months back &lt;a href=&#34;http://baoilleach.blogspot.co.uk/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Noel O&amp;rsquo;Boyle&lt;/a&gt; wrote a series of blog posts wherein he used &lt;a href=&#34;http://kripken.github.io/emscripten-site/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Emscripten&lt;/a&gt;&#xA;to compile a number of chemoinformatics toolkits to Javascript including &lt;a href=&#34;http://baoilleach.blogspot.com/2015/02/cheminformaticsjs-open-babel.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenBabel&lt;/a&gt;,&#xA;&lt;a href=&#34;http://baoilleach.blogspot.com/2015/02/cheminformaticsjs-rdkit.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;RDKit&lt;/a&gt;, and &lt;a href=&#34;http://baoilleach.blogspot.com/2015/02/cheminformaticsjs-helium.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Helium&lt;/a&gt;. As someone interested in using the browser to interact with molecules, I thought this was a great series of posts and thought I might even be able to reuse some of the javascript he had generated. However, upon attempting to reuse his smiles-to-svg functions on a different webpage I discovered that output of Emscripten is difficult to reuse (or at least not obvious to someone unfamiliar with &lt;a href=&#34;http://asmjs.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;ASM.js&lt;/a&gt;. I tried downloading&#xA;the JS file in order to call the smiles-to-svg function in another context but started running into errors with the generated code. I was still interested in trying to generate images in the browser, however, and in his &lt;a href=&#34;http://baoilleach.blogspot.com/2015/02/cheminformaticsjs-conclusion.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;final post&lt;/a&gt;, Noel points the way by mentioning the &lt;a href=&#34;https://github.com/kemia/kemia&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;kemia&lt;/a&gt; project, a javascript chemistry library that aims to be &amp;ldquo;the world’s first open source, 100% javascript chemistry toolkit.&amp;rdquo; The rest of this post is how I used kemia, ChemDoodle, and clojurescript to make pure-browser smiles-to-canvas widget.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Process Substitution and BioPython</title>
				<link>http://zachcp.org/blog/process_substitution/</link>
				<pubDate>Wed, 20 May 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/process_substitution/</guid>
				<description>&lt;p&gt;I recently picked up a copy of Vince Buffalo&amp;rsquo;s &lt;a href=&#34;http://www.amazon.com/Bioinformatics-Data-Skills-Reproducible-Research/dp/1449367372?tag=duckduckgo-d-20&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Bioinformatics Data Skills&lt;/a&gt; and have learned a few gems. There is one section where he discusses the uses of named pipes and process substitution, (blogpost about it &lt;a href=&#34;http://vincebuffalo.com/2013/08/08/the-mighty-named-pipe.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;) and I wanted to try it. I also have been using the Click library for making command line scripts in python. Can I combine these together fruitfully and get the ease writing code with some of the memory-saving and computational speedups of using process substition? Indeed. Here I build up a simple script that aims to concatenate each record of a forward/reverse fastq pair and gzip the output.&lt;/p&gt;</description>
			</item>
			<item>
				<title>topic histograms of PUBMED using eutils CLI</title>
				<link>http://zachcp.org/blog/ncbi_eutils/</link>
				<pubDate>Tue, 21 Apr 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/ncbi_eutils/</guid>
				<description>&lt;p&gt;I&amp;rsquo;ve needed to download and bulk analyze some abstract data from Pubmed and have taken this as an opportunity to familiarize myself with their &lt;a href=&#34;http://www.ncbi.nlm.nih.gov/books/NBK179288/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;eutils command line interface&lt;/a&gt;. The command line interface to eutils gives you full access to NCBI&amp;rsquo;s many databases but allows you to perform queries in a sophisticated way. The few, core set of commands can perform fairly sophisticated analyses by chaining the calls together with pipes, unix-style. &lt;strong&gt;esearch&lt;/strong&gt;, &lt;strong&gt;efilter&lt;/strong&gt;, and &lt;strong&gt;efetch&lt;/strong&gt; are the primary means of looking for, filtering and obtaining data, while the &lt;strong&gt;xtract&lt;/strong&gt; command parses the XML data from NCB into useable formats. The examples in the documentation in the link above are enough to get you started and to see how the tools let you explore the data (i would use a filter on the big searches to reduce search time) and iterate the discovery/retrieval process&lt;/p&gt;</description>
			</item>
			<item>
				<title>Sequence Server</title>
				<link>http://zachcp.org/blog/sequence-server-setup/</link>
				<pubDate>Tue, 07 Apr 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/sequence-server-setup/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;http://www.sequenceserver.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Sequnceserver&lt;/a&gt; is a webserver that can be run locally and will provide a slick interface to &lt;a href=&#34;ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast&amp;#43;/LATEST/&#34;&gt;Blast&lt;/a&gt; for any sequence data you may have. Any lab with a fair amount of sequence data will find this tool to be useful. Heres a few notes on our setup.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#We&#39;re using a local machine with RHEL6.4 Make sure blast and ruby are installed.&#xA;yum install ncbi-blast&#xA;yum install ruby           # probably already installed&#xA;gem install sequenceserver # Boom! simple as that&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Sequenceserver&amp;rsquo;s config file. &lt;code&gt;~/.sequenceserver.conf&lt;/code&gt; allows you to specify the folder with your blast databases, change the port it is served on, and the number of threads/cpus you make available to blast. I put the sequence server folder in its own directory and link all of the blast databases to it. That way I can keep big NCBI databases like NT and NR in their own folders. I can also keep lab-generated data organized in their own folders with their own documentation.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Wildcards in Make</title>
				<link>http://zachcp.org/blog/wildcards-in-make/</link>
				<pubDate>Wed, 18 Feb 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/wildcards-in-make/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://www.gnu.org/software/make/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Make&lt;/a&gt; is a tool initially developed by software developers to build their source code but it has found another home in data analysis and reproducible research.  Mike Bostock&amp;rsquo;s excellent &lt;a href=&#34;http://bost.ocks.org/mike/make/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;make overview&lt;/a&gt; outlines the main benefits: a concise way to show all of the steps necessary to build something - in his case a visualization.  Karl Broman&amp;rsquo;s &lt;a href=&#34;http://kbroman.org/minimal_make/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;make tutorial&lt;/a&gt; is a second excellent introduction make, in this case in the context of creating a completely reproducible research paper. One of Karl&amp;rsquo;s examples is the use of the &lt;strong&gt;wildcard&lt;/strong&gt; which allows you to use pattern matching to process lots of files in a simple, declarative way. Anyone new to make will probably have a bit of difficulty with the syntax but once mastered it can be incredibly useful to represent data processing steps for large, multistep projects. This is a very powerful tool for data processing and I wanted to highlight how the wildcards can be used for data processing.&lt;/p&gt;</description>
			</item>
			<item>
				<title>PCR Animation with Pymol</title>
				<link>http://zachcp.org/blog/pcr_animation/</link>
				<pubDate>Fri, 06 Feb 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/pcr_animation/</guid>
				<description>&lt;img src=&#34;http://zachcp.org/pics/blog/2015/animation.gif&#34;&gt;&#xA;&lt;p&gt;I was cleaning up some old files and uncovered the code I used to create a PCR-like animation for the &lt;a href=&#34;https://www.youtube.com/watch?v=oCRJ4r0RDC4&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PCR Rap&lt;/a&gt; and I&amp;rsquo;ve posted it to &lt;a href=&#34;https://github.com/zachcp/pcrviz&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The animation (seen above) is made in Pymol and uses a series of rotations and translations of a polymerase around a double stranded DNA. At the time I remember struggling with setting the view, coordinating the state of each polymerase and DNA strand and so instead of banging&#xA;my head against PyMol I simple wrote a script that would write out the commands that I wold normally use in pymol and then run that script in pymol. it worked fine in the end but something like &lt;a href=&#34;https://github.com/quil/quil&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Quil&lt;/a&gt;/Processing is how I would do it if i was writing again. Quill interface to &lt;a href=&#34;http://jmol.sourceforge.net/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMOL&lt;/a&gt;, anyone?&lt;/p&gt;</description>
			</item>
			<item>
				<title>CDK Plotting Basics: Rotation and Center-Translation</title>
				<link>http://zachcp.org/blog/basic-cdk-rendering/</link>
				<pubDate>Thu, 22 Jan 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/basic-cdk-rendering/</guid>
				<description>&lt;img src=&#34;http://zachcp.org/pics/blog/2015/caffeinerepeat.png&#34;&gt;&#xA;&lt;p&gt;&lt;em&gt;tl;dr plotting molecules is fun once you get the hang of it.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This post is a continuation of my &lt;a href=&#34;http://zachcp.org/blog/2015/clojure-cdk-peptides/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;previous post&lt;/a&gt;, wherein I began playing with the &lt;a href=&#34;https://github.com/cdk/cdk&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Chemistry Development Kit (CDK)&lt;/a&gt; for the purpose of making visualizations. CDK does a great job of generating structures of small molecules, but what if you want to scale, transform, or rotate these molecule on your canvas? Its not quite as easy as it seems.&lt;/p&gt;</description>
			</item>
			<item>
				<title>A Simple Peptide Viz Tool in Clojure using CDK</title>
				<link>http://zachcp.org/blog/clojure-cdk-peptides/</link>
				<pubDate>Mon, 19 Jan 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/clojure-cdk-peptides/</guid>
				<description>&lt;p&gt;&lt;em&gt;tl;dr don&amp;rsquo;t write your own chemistry library if a good one exists and CDK is a good one; clojure has good java interop but it still requires you to learn the classes/interfaces in that library; start simple and small&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I work in a field at the crossroads of chemistry and biology. The powerful tools of molecular genetics and biochemistry have led to an understanding of how genes and their &amp;ldquo;gene-products&amp;rdquo; (proteins) alter and combine basic chemicals to make all of the components that living beings require. In the microbial world, the understanding of these gene-protein-metabolite networks is driving several areas of science where the major conceptual ideas are to either engineer the metabolic systems to maximize the output of a particular metabolite (biofuels, pharmaceutical precursors) or to use the genetic diversity that exists in nature to try to find novel metabolites. Our lab is interested in the latter: we hope to use naturally occurring genetic diversity to find collections of genes making new molecules. While there are lots of tools for visualizing genes, and great tools for plotting particular compounds, there is a neglected middle ground for visualizing all of these things together and I wanted to write a little visualization tool for that purpose.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Python to Clojure: Getting Used to Immutability</title>
				<link>http://zachcp.org/blog/python-to-clojure/</link>
				<pubDate>Tue, 06 Jan 2015 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/python-to-clojure/</guid>
				<description>&lt;p&gt;&lt;em&gt;tl;dr clojure is an interesting language emphasizing immutable data and higher order functions. While these offer some tangible benefits, effective use requires a style of thinking about programming that is quite different from the imperative style many of us know&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have been following the &lt;a href=&#34;http://clojure.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Clojure&lt;/a&gt; community for a little while and have been interested in their way of doing things. Not only are there a lot of smart people who have been involved in designing the language, but the support for both the JVM and for Javascript means that Clojure is a language that may yield a single language to &amp;ldquo;rule them all&amp;rdquo;, or at least to allow portability to just about any platform. JVM plus JS is a pretty nice combo. That Clojure is a lisp is also appealing since hearing of how lisp was Paul Graham&amp;rsquo;s &amp;ldquo;secret weapon&amp;rdquo; in &lt;a href=&#34;http://www.paulgraham.com/avg.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Beating the Averages&lt;/a&gt;. But in addition to being a lisp, Clojure prides itself on immutable data and functional programming. These two are interesting concepts that are catching on in many areas of programming and are in the same spirit of reproducible research where the processing and analysis of data should be as transparent as possible and should focus on what we are ultimately interested in: the values themselves.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Going Parallel with multiprocessing</title>
				<link>http://zachcp.org/blog/parallel_with_multiprocessing/</link>
				<pubDate>Fri, 12 Dec 2014 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/parallel_with_multiprocessing/</guid>
				<description>&lt;p&gt;For a current project I need to debarcode MiSeq-sequenced amplicons that were generated by two rounds of PCR, each of which used a barcoded primer. I will use Qiime&amp;rsquo;s &lt;a href=&#34;http://qiime.org/scripts/split_libraries.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;split_libraries.py&lt;/a&gt; for the second set of primers but I wanted a script that can iterate through the sequences, detect some conserved bits and chop out the left part of my sequences. I came across &lt;a href=&#34;https://bcbio.wordpress.com/2009/08/09/trimming-adaptors-from-short-read-sequences/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Brad Chapman&amp;rsquo;s post&lt;/a&gt; about such a script and wanted to try it out. It was great but slow. Can I make it faster?&lt;/p&gt;</description>
			</item>
			<item>
				<title>standard evaluation in dplyr</title>
				<link>http://zachcp.org/blog/programming_with_dplyr/</link>
				<pubDate>Tue, 02 Dec 2014 08:03:00 +0000</pubDate>
				<guid>http://zachcp.org/blog/programming_with_dplyr/</guid>
				<description>&lt;p&gt;A bunch of my data analyses in the past few months had been using R to analyze large data frames. I was excited when &lt;a href=&#34;https://github.com/hadley&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Hadley&lt;/a&gt; and &lt;a href=&#34;https://github.com/romainfrancois&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Romaine&lt;/a&gt; released &lt;a href=&#34;https://github.com/hadley/dplyr&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;dplyr&lt;/a&gt;, their high performance package for dataframe analysis/manipulation. Although the performance is awesome, I think dplyr also excels in making it much easier to write R code and compose usefulf funcitons form a set of simple functions the call &amp;ldquo;verbs&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;Despite having used R a fair bit I almost always need to google/stack-overflow simple things related to the grammar of R. Subsetting, renaming, etc are not at all intuitive and I think this is part of the reasons why it is easier to pick up python/pandas due to the rather straightforward syntax. So dplyr&amp;rsquo;s straight-forward syntax of a small number of well defined &amp;ldquo;verbs&amp;rdquo; and its use of the piping operator &lt;code&gt;%&amp;gt;%&lt;/code&gt; make it an excellent choice for use in data analysis. However, there was one issue when I was using dplyr that was a bit problematic: although performing a dplyr-based data analysis pipeline was straight-forward, composing a function to do that analysis was impossible&amp;hellip;&amp;hellip;. until now.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
