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
from collections import defaultdict | |
def ordering(graph:dict): | |
in_counts = defaultdict(int) | |
for k, v in graph.items(): | |
if not k in in_counts: | |
in_counts[k] = 0 | |
for in_node in v: | |
in_counts[in_node] += 1 |
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 itertools | |
from Bio import SeqIO | |
def overlap(read_a, read_b, min_length): | |
start = 0 | |
while True: | |
start = read_a.find(read_b[:min_length], start) | |
if start == -1: | |
return 0 | |
if read_b.startswith(read_a[start:]): |
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 itertools | |
from Bio import SeqIO | |
def overlap(read_a, read_b, min_length): | |
start = 0 | |
while True: | |
start = read_a.find(read_b[:min_length], start) | |
if start == -1: | |
return 0 | |
if read_b.startswith(read_a[start:]): |
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
from collections import defaultdict | |
from Bio import SeqIO | |
def overlap(kmer_left, kmer_right, overlap_size): | |
return kmer_left[-overlap_size:] == kmer_right[:overlap_size] | |
def maximal_overlap(kmer_left, kmer_right): | |
overlap_sizes = [] | |
for overlap_size in range(1, len(kmer_right) + 1): | |
has_overlap = overlap(kmer_left, kmer_right, overlap_size) |
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 sqlite3 | |
import sys | |
def get_gene_ids(gene_symbol): | |
try: | |
# estabilish a SQLIte connection from Python | |
sqlite_connection = sqlite3.connect('refGene_hg19.db') | |
# Better formatting for results | |
sqlite_connection.row_factory = lambda cursor, row: row[0] | |
# create a cursor object using the connection object |
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
#http://stackoverflow.com/a/8010133/468311 | |
with open(...) as f: | |
for line in f: | |
<do something with line> |