Skip to content

Instantly share code, notes, and snippets.

import itertools
def all_perm(word):
# prints all permutation to a given word
for p in list(itertools.permutations(word)):
print ''.join(p)
all_perm("abcde")
# -*- coding: UTF-8 -*-
def upside_down(inp):
#print upside-down of a given alphabetic string
rev_dict = {'z': u'z', 'y': u'ʎ', 'x': u'x',
'w': u'ʍ', 'v': u'ʌ', 'u': u'n',
't': u'ʇ', 's': u's', 'r': u'ɹ',
'q': u'b', 'p': u'd', 'o': u'o',
'n': u'u', 'm': u'ɯ', 'l': u'\u0285',
'k': u'ʞ', 'j': u'ɾ', 'i': u'ᴉ',
import glob
import os, time
time_and_file=dict()
folder_name=raw_input()
ct=1
#assuming folder at the same directory as script
for filename in glob.glob(folder_name+"/*.*"):
name=filename.split('.')[0]
try:
#___________myproject/settings.py__________
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'anotherapp',
'activitystream'
{"test_name":"TCHO","level_1_lower_range":10,"level_1_upper_range":20,"level_2_lower_range":20,"level_2_upper_range":30,"level_3_lower_range":30,"level_3_upper_range":40}
@Ruhshan
Ruhshan / aa_comp.R
Created November 9, 2017 18:00
read a fasta file and gets amino acid composition for all proteins then writes to csv
library(Peptides)
library(seqinr)
get_comp <- function(fasta){
s=getSequence(fasta, as.string = TRUE);
sname=getName(fasta);
comp = aaComp(s);
r<-c(name=sname,
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for epoch in range(n_epochs):
epoch_loss = 0
i=0
while i < len(train_x):
start = i
end = i+batch_size
batch_x = np.array(train_x[start:end])
def get_train_data_batch(n):
features = []
with open('data.csv') as f:
count=0
for line in f:
splitted = line.split(';')
featureset = [int(float(x)) for x in splitted[:len(splitted)-1]]
label = int(float(splitted[-1].rstrip()))
count+=1
if count % n==0:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for epoch in range(n_epochs):
train_data_batch_gen = get_train_data_batch(batch_size)
epoch_loss = 0
i=0
while i < total_lines:
train_x, train_y = next(train_data_batch_gen)
batch_x = np.array(train_x)
findcommunities <- function(mygraph,minsize)
{
# Function to find network communities in a graph
# Load up the igraph library:
require("igraph")
# Set the counter for the number of communities:
cnt <- 0
# First find the connected components in the graph:
myconnectedcomponents <- connectedComp(mygraph)
# For each connected component, find the communities within that connected component: