Skip to content

Instantly share code, notes, and snippets.

View Winterflower's full-sized avatar
🥰
Learning all about NLP!

Camilla Montonen Winterflower

🥰
Learning all about NLP!
View GitHub Profile
# -*- coding: utf-8 -*-
def kmer(sequence,k):
length=len(sequence)
#if the kmer size if greater than the lenght of the sequene
if k>=length:
print "You specified a kmer size, which if greater or equal to the length of the sequence"
return
stepsize=k-1
i=0
kmers=[]
@Winterflower
Winterflower / kmer_tree
Created June 25, 2014 13:07
generating a kmer tree with python
# -*- coding: utf-8 -*-
def kmer(sequence,k):
length=len(sequence)
#if the kmer size if greater than the lenght of the sequene
if k>=length:
print "You specified a kmer size, which if greater or equal to the length of the sequence"
return
stepsize=k-1
i=0
kmers=[]
# -*- coding: utf-8 -*-
#make a tree of all the possible kmers in a given alphabet
#this method creates a subtree given an alphabet and a parentnode
def maketree(alphabet,parentnode):
for letter in alphabet:
parentnode.append([letter])
return parentnode
print "======================TESTING METHOD: MAKETREE==================="
@Winterflower
Winterflower / permutation.py
Created June 29, 2014 09:08
another permutation
from itertools import product
for roll in product(['A','C','T','G'], repeat = 6):
print(roll)
allkmers=[]
kmers=product(['A','C','T','G'],repeat=6)
@Winterflower
Winterflower / kmersvm.py
Created July 15, 2014 12:34
Understanding the kmersvm
from modshogun import StringCharFeatures,DNA
from modshogun import StringWordFeatures
#training set
train_dna=['ACGTGT',
'ACGGTT',
'AGTGTT',
'ACCGGT',
'TGTGTA',
'TTGGGT']
try:
from shogun.PreProc import SortWordString, SortUlongString
except ImportError:
from shogun.Preprocessor import SortWordString, SortUlongString
from shogun.Kernel import CommWordStringKernel, CommUlongStringKernel, \
CombinedKernel
from shogun.Features import StringWordFeatures, StringUlongFeatures, \
StringCharFeatures, CombinedFeatures, DNA, Labels
from shogun.Classifier import MSG_INFO, MSG_ERROR
@Winterflower
Winterflower / sendeth.py
Created October 28, 2015 21:46 — forked from cslarsen/sendeth.py
One way of sending raw Ethernet packets in Python
"""Demonstrates how to construct and send raw Ethernet packets on the
network.
You probably need root privs to be able to bind to the network interface,
e.g.:
$ sudo python sendeth.py
"""
from socket import *
@Winterflower
Winterflower / rxpy_example_1.py
Created February 4, 2017 15:32
Simple example of RxPy usage
"""
Simple RxPy example
"""
from rx import Observer, Observable
from numpy import random
class DataAnalyser(Observer):
#a class for analyzing data
def on_next(self, value):