Skip to content

Instantly share code, notes, and snippets.

@radaniba
radaniba / convertformat.py
Created November 29, 2012 17:00
A simple Python script to convert biosequences between different formats.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Convert biosequences from one format to another.
Usage is: convbioseq [options] FORMAT INFILES ...
Options:
--version show program's version number and exit
@radaniba
radaniba / rpkmforgenes.py
Created November 29, 2012 17:17
The python script rpkmforgenes.py is written for calculating gene expression for RNA-Seq data. It was used for a study published in PLoS Computational Biology (Ramsköld D, Wang ET, Burge CB, Sandberg R. An abundance of ubiquitously expressed genes reveale
Sequence data input:
A common input file format is bed file. In the simplest form, it has the format
chromosome -tab- startposition -tab- endposition
where each line corresponds to one sequence read
However this format can also include strand information:
chromosome -tab- startposition -tab- endposition -tab- name -tab- score -tab- +/-
for example:
chr13 54005048 54005081 . 1 -
The score field is ignored.
Files are allowed by have an optional first line starting with "track", this line is then ignored
@radaniba
radaniba / SmithWaterman.py
Created April 18, 2014 01:03
Smith Waterman Implementation in Python
#!/Users/Rad/anaconda/bin/python
# (c) 2013 Ryan Boehning
'''A Python implementation of the Smith-Waterman algorithm for local alignment
of nucleotide sequences.
'''
import argparse
@radaniba
radaniba / parsefasta.html
Created November 29, 2012 16:53
Parse fasta with Javascript
#I found this stuff interesting to share, more on http://code.google.com/p/bio-js/
#This is my attempt at a bioinformatics framework in JavaScript. I've noticed more and more bioinformatics interfaces going live online, and so we are in a kind of cloud-computing era in bioinformatics. For example, there are many sites out there which let a user paste FASTA sequences into a web form. Things like parsing FASTA files should be easy to do and should be object oriented. I have decided on using the existing framework PrototypeJS to facilitate the process and to ensure that the project is compatible with most operating systems and browsers.
#Example
<html>
<head>
<title>Bio-JS Test</title>
<script src='lib/prototype.js' type='text/javascript'></script>
@radaniba
radaniba / django_deploy.md
Created April 26, 2021 03:22 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@radaniba
radaniba / test.json
Last active December 15, 2020 14:48
test
{"name": "AS", "children": [{"name": "BSP_UM-SAL_AS_12", "children": [{"name": "FLOW-B_AS_12", "children": [{"name": "FLOW-B_AS_12_2", "size": 200}, {"name": "FLOW-B_AS_12_1", "size": 200}, {"name": "FLOW-B_AS_12_3", "size": 200}, {"name": "FLOW-B_AS_12_4", "size": 200}]}, {"name": "RNA-B_AS_12", "size": 200}]}, {"name": "BSP_PAX-B_AS_34", "size": 200}]}
@radaniba
radaniba / getnucseq.py
Created November 29, 2012 17:06
Obtaining the actual sequence making up a gene from NCBI is simple using a browser, but not so much when wanting to do it in batch. This script obtains the nucleotide sequences, mRNA's, CDS's and protein sequences associated with a list of gene IDs.
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
from Bio import Entrez
from Bio import SeqIO
import time
# Obtain your gene IDs from somewhere (file, past text directly, etc.)
ids = []
ids = ",".join( lines )
@radaniba
radaniba / csv-to-mysql.py
Created November 29, 2012 17:08
Python CSV to MySQL
#!/usr/bin/env python
# Run with no args for usage instructions
#
# Notes:
# - will probably insert duplicate records if you load the same file twice
# - assumes that the number of fields in the header row is the same
# as the number of columns in the rest of the file and in the database
# - assumes the column order is the same in the file and in the database
#
@radaniba
radaniba / parsegb.rb
Created November 29, 2012 16:56
Parse Genbank with BioRuby
#You can parse Genbank bank files with BioRuby the standard way, but there's a hidden problem. If the file ends with blank lines, i.e. after the genbank terminator (two forwards slashes, //) there are empty lines, BioRuby reads these as additional, empty records. However, you can route around this by trimming the blank lines before handing it to the parser.
puts "Parsing seqs ..."
Bio::FlatFile.auto("foo.genbank").each_entry { |gb|
puts "Sequence '#{gb.to_biosequence.entry_id}'"
}
puts "Finished."
which will print the id of every sequence in the file. However, if the file ends with blank lines, i.e. after the genbank terminator (two forwards slashes, which the wiki markup doesn't like) there are empty lines, BioRuby reads these as additional, empty records:
@radaniba
radaniba / my_vimrc
Last active October 12, 2016 18:09
" set runtimepath+=~/.vim_runtime
" source ~/.vim_runtime/vimrcs/basic.vim
" source ~/.vim_runtime/vimrcs/filetypes.vim
" source ~/.vim_runtime/vimrcs/plugins_config.vim
" source ~/.vim_runtime/vimrcs/extended.vim
" try
" source ~/.vim_runtime/my_configs.vim
" catch