Skip to content

Instantly share code, notes, and snippets.

View jmchilton's full-sized avatar

John Chilton jmchilton

  • Penn State University
  • Pittsburgh, PA
  • X @jmchilton
View GitHub Profile
import java.io.InputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Properties;
import com.google.gwt.i18n.client.Constants;
public class ConstantProxies {
@jmchilton
jmchilton / preseed.py
Created March 5, 2012 17:21
Example preseed script
# Place this file (preseed.py) in your galaxy directory and run it via
# python preseed.py
from scripts.db_shell import *
admin_user = User("admin@localhost")
admin_user.set_password_cleartext("test1")
sa_session.add(admin_user)
sa_session.flush()
user = User("user@localhost")
public Ratios computeRatios(final ITraqLabel numLabel, final ITraqLabel denLabel, final ReportSummary reportSummary,
final Function<Double, Double> weightFunction) {
final double[] ratios = new double[reportSummary.getNumProteins()], pValues = new double[reportSummary.getNumProteins()];
int proteinNum = 0;
for(final String protein : reportSummary.getProteins()) {
final ProteinSummary proteinSummary = reportSummary.getProteinSummary(protein);
final double[] iRatio = new double[proteinSummary.getNumEntries()];
final double[] num = proteinSummary.getIntensities(numLabel);
final double[] den = proteinSummary.getIntensities(denLabel);
@jmchilton
jmchilton / gist:3480469
Created August 26, 2012 14:41
sed/awk examples
# Using arrays
grep "identification.*user.*Running" sed_test | sed 's/[^\[]*\[\([\: 0-9\-]*\).*\jobName=\(.*\)\,jobId=\([0-9]*\).*/\1\t\3\t\2/' | awk 'BEGIN {i=0;lj=0} {if(lj!=$2) {i=i+1}; lj=$2; if(s[i]==""){s[i]=e[i]=$1;t[i]=$3}; e[i]=$1;} END{ print i;for(idx=1;idx<=i;idx++){ cmd="date --date=\"" s[idx] "\" +%s"; cmd | getline se; cmd="date --date=\"" e[idx] "\" +%s"; cmd | getline ee; print (ee - se) / 60, "\t" t[idx]}}' FS="\t"
# Improvement using hashs
grep "identification.*user.*Running" sed_test | sed 's/[^\[]*\[\([\: 0-9\-]*\).*\jobName=\(.*\)\,jobId=\([0-9]*\).*/\1\t\3\t\2/' | awk 'BEGIN {i=0;lj=0} {i=$2$3; lj=$2; if(s[i]==""){s[i]=e[i]=$1;t[i]=$3}; e[i]=$1;} END{ print i;for(idx in s){ cmd="date --date=\"" s[idx] "\" +%s"; cmd | getline se; cmd="date --date=\"" e[idx] "\" +%s"; cmd | getline ee; print (ee - se) / 60, "\t" t[idx]}}' FS="\t"
@jmchilton
jmchilton / README_GALAXYP.md
Created September 19, 2012 13:42
Shared README sections for all Galaxy-P tools

Obtaining Tools

Repositories for all Galaxy-P tools can be found at https:/bitbucket.org/galaxyp/.

Contact

Please send suggestions for improvements and bug reports to jmchilton@gmail.com.

@jmchilton
jmchilton / gist:3984862
Created October 31, 2012 04:56
Example of initializing GalaxyInstance object when OS doesn't trust remote certificate.
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
...
@jmchilton
jmchilton / gist:3988285
Created October 31, 2012 16:57
Handler refactoring1
diff -r b2975e2fa684 lib/galaxy/jobs/handler.py
--- a/lib/galaxy/jobs/handler.py Fri Oct 26 12:56:23 2012 -0400
+++ b/lib/galaxy/jobs/handler.py Wed Oct 31 12:00:10 2012 -0500
@@ -397,6 +397,11 @@
def put( self, job_wrapper ):
try:
runner_name = self.__get_runner_name( job_wrapper )
+ except Exception:
+ log.exception( 'Failed to generate job runner name' )
+ job_wrapper.fail( 'Unable to run job due to a misconfiguration of the Galaxy job running system. Please contact a site administrator.' )
@jmchilton
jmchilton / gist:3988522
Created October 31, 2012 17:32
dynamic job runner exception enhancement
diff -r ec3b5956130f lib/galaxy/jobs/handler.py
--- a/lib/galaxy/jobs/handler.py Wed Oct 31 12:18:55 2012 -0500
+++ b/lib/galaxy/jobs/handler.py Wed Oct 31 13:42:38 2012 -0500
@@ -17,6 +17,7 @@
# States for running a job. These are NOT the same as data states
JOB_WAIT, JOB_ERROR, JOB_INPUT_ERROR, JOB_INPUT_DELETED, JOB_READY, JOB_DELETED, JOB_ADMIN_DELETED = 'wait', 'error', 'input_error', 'input_deleted', 'ready', 'deleted', 'admin_deleted'
+DEFAULT_JOB_PUT_FAILURE_MESSAGE = 'Unable to run job due to a misconfiguration of the Galaxy job running system. Please contact a site administrator.'
class JobHandler( object ):
@jmchilton
jmchilton / softacct_databases
Created November 9, 2012 18:37
MSI Software Accounting Databases
<p>There are currently two software accounting databases. MSIdb contains the most up-to-date demographic, resource, and FLEXlm records but not collectl data. All collectl data is stored in an appdev managed database on appdev-dom0, the demographic, resource and FLEXlm records are occasionally copied over from MSIdb to appdev-dom0.</p>
<p>Both of these databases can be access from loon.msi.umn.edu. To access you will first need to create a .pgpass file in your home directory.</p>
<pre>
% touch $HOME/.pgpass; chmod 600 $HOME/.pgpass; cat /project/msistaff/appdev/softacct/PGPASS_EXAMPLE >> $HOME/.pgpass
</pre>
<p>Once your .pgpass file is setup, you can access the appdev-dom0 database from loon with the following command:</p>
<pre>
@jmchilton
jmchilton / gist:4052592
Created November 10, 2012 21:32
Walking through galaxy job submission.
Galaxy Tool/Job Running:
---------------------
Entry points:
lib/webapps/galaxy/controllers/tool_runner.py (method: index)
lib/webapps/galaxy/api/tools.py (method: create)
Generate tool from id.
Setup params: