Skip to content

Instantly share code, notes, and snippets.

@sestaton
sestaton / biostars140225.pl
Created May 1, 2015 16:30
benchmark sting formatting
#!/usr/bin/env perl
use 5.020;
use strict;
use warnings;
use Benchmark qw(:all);
my $seq = "ATCG" x 25e6; # 100Mb string
my $count = 10;
@sestaton
sestaton / custom_num_subtype.pl
Last active August 29, 2015 14:20
small test for creating custom moose types
package test::role;
use Moose::Role;
use Moose::Util::TypeConstraints;
subtype 'ModNum'
=> as 'Num'
=> where { /\_/ || /\d+/ };
coerce 'ModNum',
@sestaton
sestaton / biostars163769.pl
Last active November 17, 2015 15:44
minimal genbank to fasta conversion
use strict;
use warnings;
my ($def, $seq);
while (<>) {
if (/^DEFINITION\s+(\S+.*)$/) {
$def = $1;
}
if (/^ORIGIN/) {
@sestaton
sestaton / fetch_by_seq.pl
Last active February 11, 2016 11:59
Fetch FASTA records by sequence
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename;
my $usage = "perl ".basename($0)." seqsi.fas seqsj.fas > seqs_out.fas";
my $infilei = shift or die $usage;
my $infilej = shift or die $usage;
@sestaton
sestaton / fmtDetailValue_Dbxref.js
Last active July 4, 2018 04:56
create dbxref links for jbrowse
fmtDetailValue_Dbxref : function(dbxref) {
if (typeof dbxref != 'string') {
return dbxref;
}
var dbid = dbxref.split(':');
var prefix = '';
switch (dbid[0]) {
case 'InterPro':
prefix = 'http://www.ebi.ac.uk/interpro/entry/';
break;
@sestaton
sestaton / fmtDetailValue_Ontology_term.js
Created May 12, 2016 20:58
create GO term links for jbrowse
fmtDetailValue_Ontology_term : function(goterm) {
if (typeof goterm != 'string') {
return goterm;
}
var dbid = goterm.split(':');
var prefix = '';
switch (dbid[0]) {
case 'GO':
prefix = 'http://amigo.geneontology.org/amigo/medial_search?q=GO:';
break;
@sestaton
sestaton / ss_links.rb
Created May 18, 2016 17:02
create links to sunflower jbrowse from blast server
@sestaton
sestaton / biostars192376.py
Last active May 18, 2016 20:44
get ncbi ftp listing
from ftplib import FTP
host = "ftp.ncbi.nlm.nih.gov"
wdir = "/genomes/refseq/"
ftp = FTP(host, 'anonymous', 'anonymous')
ftp.set_pasv(1)
list = ftp.nlst(wdir)
print len(list)
@sestaton
sestaton / biostars192376.pl
Last active May 18, 2016 21:02
get ncbi ftp listing
use strict;
use warnings;
use Net::FTP;
my $host = "ftp.ncbi.nlm.nih.gov";
my $wdir = "/genomes/refseq/";
my $ftp = Net::FTP->new($host, Passive => 1, Debug => 0)
or die "Cannot connect to $host: $@";
@sestaton
sestaton / biostars194306.pl
Last active May 31, 2016 20:23
Simple script to get sequences from UniProt
# always include these lines! (implicit in recent Perl versions)
use strict; # follow the rules
use warnings; # warning when we make a mistake
# import method to perform the request
use LWP::UserAgent;
# make the format an option perhaps
my $format = 'fasta';
my $urlbase = 'http://www.uniprot.org/uniprot/';