This file contains 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
# Rename all *.txt to *.text | |
for f in *.txt; do | |
mv -- "$f" "${f%.txt}.gbk" | |
done |
This file contains 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/python3 | |
from subprocess import Popen,PIPE,STDOUT | |
pmidString='' | |
command='/home/glwinsor/edirect/efetch -db pubmed -id 153904' | |
#captures STDOUT without having to use a redirect to a filename | |
#note that it captures bytes, not a string. Therefore need to specify universtal_newlines=True in order to retain newlines |
This file contains 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/python3 | |
f = open('filename.txt', 'w') | |
f.write() | |
f.close() |
This file contains 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
from optparse import OptionParser | |
import pymysql | |
# Get options from the command line | |
parser = OptionParser() | |
parser.add_option("-d", "--database", dest="database", action="store", type="string", help="Name of database you wish to connect to", metavar="DATABASE") | |
parser.add_option("-H", "--host", dest="host", action="store", type="string", help="Database host", metavar="HOST") | |
parser.add_option("-u", "--user", dest="user", action="store", type="string", help="User name", metavar="NAME") | |
parser.add_option("-p", "--password", dest="password", action="store", type="string", help="Password", metavar="PASSWORD") |
This file contains 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
from Bio import SeqIO | |
# read in the fasta file and create seq object. File name is stored in fasta variable and the following "fasta" in quotes means the type of format being input | |
for seq_record in SeqIO.parse(fasta,"fasta"): | |
# Prints the sequence ID | |
print(seq_record.id) | |
# Prints string representation of the sequence | |
print(str(seq_record.seq)) |
This file contains 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 sys | |
from optparse import OptionParser | |
try: | |
# assumes file was specified as argument in the command line using optparse with --file option | |
file=open(options.file, 'r') | |
except FileNotFoundError: # works for python3 | |
print("Could not find file") | |
sys.exit() |
This file contains 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 os | |
if not os.path.isfile("./file.txt"): | |
raise FileNotFoundError("Could not find ./file.txt") | |
if not os.path.isdir('./dir'): | |
raise FileNotFoundError("Could not find ./dir") |
This file contains 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
from optparse import OptionParser | |
# Get options from the command line | |
parser = OptionParser() | |
parser.add_option("-f", "--flag", dest="flag", action="store", type="string", help="Description of flag", metavar="FLAG") | |
(options, args) = parser.parse_args() | |
if options.flag == None: | |
parser.error("Missing argument for --flag ") |
This file contains 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
// vim: syntax=perl | |
my %CONF; | |
open my $configfile, '<', 'config.txt' or die $!; | |
while (<$configfile>) { | |
chomp; | |
my ( $key, @value ) = split( "=", $_ ); | |
$CONF{$key} = join '=', @value; | |
} |
This file contains 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 -w | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use DBI; | |
my $database = ''; | |
my $password = ''; | |
my $user = ''; |