Skip to content

Instantly share code, notes, and snippets.

View robsyme's full-sized avatar

Robert Syme robsyme

View GitHub Profile
require "rubygems"
require "bio"
filepath = '/media/Store/data/sn15_genes/080611_sn15_aagi_gene.fas'
Bio::FlatFile.open(filepath) do |flatfile|
flatfile.each do |entry|
puts entry.entry_id
puts entry.seq
puts entry.seq.reverse_complement
#!/bin/bash
echo "Starting script now..."
sleep 5m
vlc ~/Music/im_going_to_kill_you.mp3 --volume 1024
echo "Script done"
%-3.fa: %-1.fa
awk '/^>/ { getline s; if ($$3/($$2-$k+1)>=$c) \
{ print $$0 "\n" s } }' $< \
|ABYSS $v -k$k -l$l -e0 -o $@ -
<BlastOutput>
<BlastOutput_iterations>
<Iteration>
<Iteration_query-def>10000_g</Iteration_query-def>
<Iteration_hits>
<Hit>
<Hit_def>hypothetical protein SNOG_01615</Hit_def>
<Hit_hsps>
<Hsp>
<Hsp_score>1420</Hsp_score>
#!/usr/bin/ruby
require "xml/libxml"
a = XML::Reader.file(ARGV.shift)
while a.read
node = a.node
if node.name == "Iteration"
iteration = XML::Document.string(node.to_s)
# We start with something like
# >1_1 [17 - 52] 53 8
# We want to end up with something like
# >Pmm_orf_00001_00001|Pmm_orf_00001_00001 17-52 [Phoma medicaginis var. medicaginis]
# Get rid of the length and coverage info (the '55 8' in the example above)
awk '/^>/ {print $1, $2, $3, $4} /^[^>]/ {print}' OMT5_6frame.fa > nojunk.fasta
# Remove the brackets and underscore
sed -e 's/\[\|\]//g' -e 's/_/ /g' nojunk.fasta > minimal.fasta
@robsyme
robsyme / genemark output renamer.awk
Created November 18, 2009 04:37
Genemark produces genes with names such as "10000_g". This little awk script pads the id with zeroes and gives a sensible name. Run awk -f scriptname filename
BEGIN {FS="_"}
/^>/ {printf ">PmpT_%05d.1|PmpT_%05d hypothetical protein [Phoma medicaginis var. medicaginis]\n", substr($1,2), substr($1,2)}
/^[^>]/ {print}
@robsyme
robsyme / abyss_renamer.awk
Created November 18, 2009 06:16
Renames fasta files from the abyss assembler
/^>/ {printf ">foxy19911_scaf_%05d_length_%d\n", substr($1,2), $2}
/^[^>]/ {print}
# See explanation here: http://picasaweb.google.com/lh/photo/iwAxZYVX1J4yuckbjBCGyg?feat=directlink
#!/usr/bin/ruby
require 'rubygems'
require 'bio'
Bio::Blast.reports(ARGF) do |report|
query_name = report.query_def
top_hit = report.hits.max {|one,two| one.bit_score <=> two.bit_score }
puts "#{query_name}\t#{top_hit.target_def}\t#{top_hit.evalue}\t#{top_hit.bit_score}"
#include <LiquidCrystal.h> // include the LiquidCrystal library
// definitions of program states
#define READY 0
#define ACTIVE 1
#define FINISHED 2
int progState = 0;
// variable declaration