This file contains hidden or 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
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
sub hamming { | |
my @a = split "", shift; | |
my @b = split "", shift; | |
my $distance = 0; | |
for (my $n = 0; $n < scalar(@a); $n++) { | |
unless (($a[$n]) eq ($b[$n])) { |
This file contains hidden or 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
#!/usr/bin/env python | |
#http://rosalind.info/problems/cons/ | |
import fastaparse | |
letters = ["A","C","G","T"] | |
sequences = [i.seq for i in fastaparse.sequences("temp2")] | |
#create empty profile matrix |
This file contains hidden or 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
sudo ntpd -gq | |
sudo hwclock --systohc --utc |
This file contains hidden or 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
#load everythin in memory | |
#split | |
def split_fasta(input_file): | |
with open(input_file) as fasta_file: | |
text = fasta_file.read().split(">")[1:] | |
data = [] | |
for entry in text: | |
header,sequence = entry.split("\n",1) | |
sequence = sequence.replace("\n","") |
This file contains hidden or 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
def qw(s,t=str): | |
return list(map(t,s.split())) |
This file contains hidden or 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
#!/usr/bin/env python | |
import fastaparse | |
import sys | |
sequences = [i.seq for i in fastaparse.parse_fasta(sys.argv[1])] | |
def substrings(string): | |
n = len(string) | |
for length in range(n,0,-1): |
This file contains hidden or 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
#!/usr/bin/env python3 | |
from ftplib import FTP | |
def ftp_download(server,remote_path,local_path,username="anonymous",password="",verbose=True): | |
#new ft object | |
ftp = FTP(server) | |
if verbose: print("Connected to %s"%server) | |
#notice that default login is "anonymous" with no password. works on most public servers |
This file contains hidden or 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 inspect | |
def render(string,variables=None): | |
"""Wrapper method for String Template: | |
name="Jeff" | |
render("Hello, $name") | |
>>Hello, Jeff | |
""" | |
t = Template(string) | |
if not variables: |
This file contains hidden or 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
#get sequences by regex match from a fasta file | |
from argparse import ArgumentParser | |
import re | |
parser = ArgumentParser(description="grep for fasta IDs") | |
group = parser.add_mutually_exclusive_group() | |
group.add_argument("--query_string","-q") | |
group.add_argument("--query_file","-f") |
This file contains hidden or 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
#!/usr/bin/perl | |
use warnings; | |
#not sure how to use strict here - does not allow bareword in "Inline CPP" | |
use Inline CPP; | |
my @data = (0..10); | |
my $result_ref = do_stuff(\@data); | |
my @result = @$result_ref; | |
print "@result\n"; | |
__END__ | |
__CPP__ |