Skip to content

Instantly share code, notes, and snippets.

View peterk87's full-sized avatar

Peter Kruczkiewicz peterk87

  • Canadian Food Inspection Agency
  • Canada
View GitHub Profile
@peterk87
peterk87 / Python: Parse binary patterns from file and get unique patterns.py
Created April 19, 2013 18:01
Python: Parse binary patterns from file and get the unique binary patterns
# assuming that the file is tab-delimited ('\t')
delim = '\t'
# binary file path:
binary_patterns_filename = "binary_patterns.txt"
# get all of the lines in the binary patterns file
lines = [line.rstrip() for line in open(binary_patterns_filename, "r")]
# 1st line should contain the headers
@peterk87
peterk87 / Parse Genbank file using BioPython.py
Last active January 7, 2022 22:33
Python: Parse Genbank file using BioPython
import os
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.SeqFeature import SeqFeature, FeatureLocation
from Bio import SeqIO
# get all sequence records for the specified genbank file
recs = [rec for rec in SeqIO.parse("genbank_file.gbk", "genbank")]
# print the number of sequence records that were extracted
@peterk87
peterk87 / comparing_partitions.py
Created April 19, 2013 19:03
Python: Calculate Adjusted Wallace, Wallace and Rand coefficients, and Simpson's index of diversity
import sys
import math
def getContTable(ar1, ar2):
cont = {}
for i in xrange(0, len(ar1)):
keyAr1 = ar1[i]
keyAr2 = ar2[i]
if keyAr1 in cont:
@peterk87
peterk87 / add_git_bash_sublime_text_to_win7_context_menus.reg
Created April 20, 2013 01:38
Reg: Create Windows 7 file explorer context menu items for ST2 and Git Bash
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Open in Sublime Text 2]
"Icon"="C:\\Program Files\\Sublime Text 2\\sublime_text.exe"
[HKEY_CLASSES_ROOT\*\shell\Open in Sublime Text 2\command]
@="\"C:\\\\Program Files\\\\Sublime Text 2\\\\sublime_text.exe\" \"%1\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\Open in Sublime Text 2\command]
@="\"C:\\\\Program Files\\\\Sublime Text 2\\\\sublime_text.exe\" \"%v\""
@peterk87
peterk87 / get_files_in_dir.py
Created April 22, 2013 16:27
Python: Get list of files containing a specified string/extension and print to stdout
import os
# get a list of files containing a certain string/extension
l = [f for f in os.listdir('.') if '.markers' in f]
lFNA = [f for f in os.listdir('.') if '.fna' in f]
# print the matching files to stdout
# get commandline command for running MIST
print 'MIST.exe -j mist.json -T tmp -t ' + ' -t '.join(l) + ' ' + ' '.join(lFNA)
@peterk87
peterk87 / gist:5439458
Last active December 16, 2015 13:08
CSS: GMail custom dark theme
.nH, .Bk, .gstt, .gbqfif, .mG, .mD, font, div.im, .amn, .hP, .Ap, .Ar.Au, .editable, .ej, .Bu, .M9, .fN, div#loading, div.nr.tMHS5d, div.ip.adB, .ef, .eh, .dW.E, .cf {
background-color: #161612!important;
color: #D7D8D1!important;
}
.gD, .gK, .gH, .ii a , iw, amt{
color: #97FFFF;
}
a {
color: #D7D8D1!important;
}
@peterk87
peterk87 / gist:5441268
Last active December 16, 2015 13:19
JSON: Sublime Text 2 user settings
{
"bold_folder_labels": true,
"fade_fold_buttons": false,
"font_size": 9,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
@peterk87
peterk87 / gist:5441280
Last active December 16, 2015 13:19
CSS: MightyText dark theme
/*Dark CSS theme for regex match of .*mightytext.net.* */
textarea, div, span, body, .nav-tabs, div#pinnedContent, .thread-tab {
background-color: rgb(30,30,30) !important;
color: rgb(170,170,170) !important;
}
span {
background-color: transparent !important;
}
a#share-button-main, a#follow-button-main, span#alert-bottom-right-corner {
visibility: hidden !important;
@peterk87
peterk87 / ipython_notebook_dark.css
Created April 23, 2013 21:15
CSS: IPython custom CSS for dark theme
/*IPython Notebook Dark CSS style*/
/*URLs matching the regexp: .*127.0.0.1:8\d\d\d.* */
body {
background-color: #111 !important;
color: #ccc !important;
}
.dropdown-menu>li>a, li, ul {
color: #ccc !important;
@peterk87
peterk87 / gist:5453001
Last active December 16, 2015 14:59
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after