Skip to content

Instantly share code, notes, and snippets.

license: gpl-3.0
@bellerbrock
bellerbrock / gist:156ef0af4eed2a023b973d32212292af
Last active January 15, 2020 18:36
Handy breedbase db migration commands
# skips first sp_person_id to exclude admin account
psql -U postgres -h breedbase_db <db_name> -c "\copy (SELECT * FROM sgn_people.sp_person where sp_person_id > 1) TO STDOUT" > people.tsv
psql -U postgres -h breedbase_db <db_name> -c "COPY sgn_people.sp_person FROM STDIN" < people.tsv
# Grant usage on all schemas to web_usr
DO $do$
DECLARE
sch text;
BEGIN
FOR sch IN SELECT nspname FROM pg_namespace
@bellerbrock
bellerbrock / Enable logging in RTT
Last active March 19, 2020 16:20
Enable logging in RTT
# Add to beginning of cgi:
import logging
import pprint
import config
pp = pprint.PrettyPrinter(indent=4)
logging.basicConfig(filename=config.ROOT_PATH+"/rtt.log", level=logging.DEBUG)
# Add debugging print statements like this
@bellerbrock
bellerbrock / Ontology Update example
Last active March 17, 2021 20:51
Ontology Update example
# Start by cloning or pulling the latest updates in the ibp-sweetpotato-traits and Chado repos
git clone https://github.com/Planteome/ibp-sweetpotato-traits.git
git clone https://github.com/GMOD/Chado.git
# Load the ontology terms, then update cvterm paths. It may be necessary to add to Chado modules to perl5lib: export PERL5LIB=/home/production/cxgn/Chado/chado/lib:$PERL5LIB
perl Chado/chado/bin/gmod_load_cvterms.pl -H db4.sgn.cornell.edu -D sandbox_batatabase -s CO_331 -d Pg -r postgres -p <PASSWORD> -n SweetpotatoTrait -u -v ibp-sweetpotato-traits/sweetpotato_trait.obo
perl Chado/chado/bin/gmod_make_cvtermpath.pl -H db4.sgn.cornell.edu -D sandbox_batatabase -d Pg -u postgres -p <PASSWORD> -c SweetpotatoTrait
# Example for other ontologies
# Retrieve NCSU crosses that are missing female_parent stock_relationship
SELECT stock.stock_id, stock.uniquename FROM stock
LEFT JOIN stock_relationship sr ON(
stock.stock_id = sr.object_id
AND sr.type_id = (SELECT cvterm_id FROM cvterm WHERE name = 'female_parent')
)
JOIN nd_experiment_stock s ON(stock.stock_id = s.stock_id)
JOIN nd_experiment_project p ON(s.nd_experiment_id = p.nd_experiment_id)
JOIN project t ON(p.project_id = t.project_id)
JOIN project_relationship pr ON(
BEGIN;
UPDATE nd_experiment
SET nd_geolocation_id = 119
WHERE nd_geolocation_id = 52;
UPDATE projectprop
SET value = '119'
WHERE value = '52'
AND type_id = (
@bellerbrock
bellerbrock / git-branching-diagram.md
Created May 12, 2023 16:05 — forked from bryanbraun/git-branching-diagram.md
Example Git Branching Diagram

Example Git Branching Diagram

You can use this diagram as a template to create your own git branching diagrams. Here's how:

  1. Create a new diagram with diagrams.net (formerly draw.io)
  2. Go to File > Open From > URL
  3. Insert this url (it points to the xml data below): https://gist.githubusercontent.com/bryanbraun/8c93e154a93a08794291df1fcdce6918/raw/bf563eb36c3623bb9e7e1faae349c5da802f9fed/template-data.xml
  4. Customize as needed for your team.