Skip to content

Instantly share code, notes, and snippets.

View describe_align.py
sbjct_aln = "C-GGLK-GAPFLAC"
query_aln = "CHG--KTGASFLQC"
gap = "-"
sbjct_idx = -1
query_idx = -1
for sbjct_resn, query_resn in zip(sbjct_aln, query_aln):
# Check for gaps
@lennax
lennax / mailstatus.py
Created Jul 29, 2015
call process and send unicode mail with status
View mailstatus.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2015 Lenna X. Peterson
# All rights reserved
import os
import socket
import subprocess
import sys
@lennax
lennax / get_torsion.py
Last active Jul 1, 2021
Script to calculate side-chain torsion angles from PDB files
View get_torsion.py
#!/usr/bin/env python
# Copyright (c) 2014 Lenna X. Peterson, all rights reserved
# lenna@purdue.edu
import argparse
import csv
import glob
import logging
import math
import os
@lennax
lennax / coord_map.py
Created Apr 13, 2014
biopython coordinate mapper example
View coord_map.py
# Copyright 2012-2014 Lenna X. Peterson
# arklenna@gmail.com
# The first step to using the mapper is to get the exons from a GenBank or similar file.
# The mapper will accept exons as a sequence of pairs, a SeqRecord with a CDS feature, or a CDS SeqFeature.
# The file used in this example is located in the Tests directory of the Biopython source code.
from Bio.SeqUtils.Mapper import CoordinateMapper
from Bio import SeqIO
View protein-ligand.sql
-- More than one chain is possible for each code
CREATE TABLE IF NOT EXISTS smallest
(
id INTEGER PRIMARY KEY NOT NULL,
code TEXT NOT NULL,
chain TEXT NOT NULL,
timestamp TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS ligands
@lennax
lennax / bareclass.py
Last active Apr 21, 2017
Minimal class
View bareclass.py
#!/usr/bin/env python
from __future__ import division
import argparse
import glob
import inspect
import logging
import os
View CoordinateMapper.py
# CoordinateMapper -- map between genomic, cds, and protein coordinates
# AUTHOR: Reece Hart <reecehart@gmail.com>
# Modifications: Lenna X. Peterson <arklenna@gmail.com>
# LICENSE: BioPython
# Examples:
# AB026906.1:g.7872G>T
# AB026906.1:c.274G>T
# BA...:p.Asp92Tyr
#
@lennax
lennax / progress_spinner.py
Created Jul 22, 2012
Updating a single printed line
View progress_spinner.py
#!/usr/bin/python
import sys
import time
spinner = ["-", "\\", "|", "/"]
print "This is the header row"
try:
for i in range(10):
@lennax
lennax / supertest.py
Created Jul 1, 2012
Quick example of multiple inheritance for alts
View supertest.py
class _AltRecord(object):
def __init__(self, alt_type, **kwargs):
print "_AltRecord"
super(_AltRecord, self).__init__(**kwargs)
self.alt_type = alt_type
class _Substitution(_AltRecord):
def __init__(self, sequence, **kwargs):
print "_Substitution"
if len(sequence) == 1:
@lennax
lennax / VariantSkeleton.py
Created May 9, 2012
Skeleton for a genomic variant interface
View VariantSkeleton.py
class Variant(object):
"""This is the top level class for genomic variants"""
def __init__(self, filename, filetype=None, gvfreader=None, vcfreader=None):
"""
Uses the default parser Wrappers unless otherwise specified.
Currently supported arguments to filetype are "vcf" and "gvf".
If filetype is not specified, guessed from file extension.
"""
self.filename = filename
if filetype is not None: