Exemplo n.º 1
0
 def __init__(self, database_name, time_between_call, logger):
     self.Database = DatabaseManager(database_name)
     self.TimeBetweenCall = time_between_call
     self.Logger = logger
     self.Options = OptionValues(BadDragonApi(self.Logger))
     self.UserFilter = {}
     self.ToyInShop = {}
     self.Parser = ArgParser(self.Options)
     self.toy_from_database()
     self.TwitterThread = []
Exemplo n.º 2
0
Arquivo: wrhp.py Projeto: wmarsey/wrhp
def main():
    argparse = ArgParser(sys.argv[1:])
    try:
        params, flags = argparse.run()
    except ValueError:
        print_exception(sys.exc_info()[0], sys.exc_info()[1], None)
        sys.exit(errno.EINVAL)
    if not params:
        sys.exit(0)

    cli = WikiCLI(params, flags)
    sys.exit(cli.run())
Exemplo n.º 3
0
def main():
    argparse = ArgParser(sys.argv[1:])
    try:
        params, flags = argparse.run()
    except ValueError:
        print_exception(sys.exc_info()[0], sys.exc_info()[1], None)
        sys.exit(errno.EINVAL)
    if not params:
        sys.exit(0)

    cli = WikiCLI(params, flags)
    sys.exit(cli.run())
Exemplo n.º 4
0
from Bio import SeqIO

from chipseqdb import *
from chipseqdb_api import *

from argParser import ArgParser
ap = ArgParser(sys.argv)

from plot_scatter import *
"""Jump allows for some steps to be skipped."""
jump = ap.getOptionalArg("--jump")
stop = ap.getOptionalArg("--stop")
if jump == False:
    jump = 0
else:
    jump = float(jump)

if stop == False:
    stop = 10000000
else:
    stop = float(stop)


def read_motifs(motif_path):
    """Reads PSWM data from a text file.
    Motifs are expected to look like this:
    
    /NAME=[SWISS] ABF1 TYPE=PSFM SPECIES=S.cer
    0.208782    0.155386    0.135415    0.500414
    0.745936    0.0    0.254063    0.0
    0.0    0.0    0.0    1.0
#################################################
#
# USAGE:
#
# python compare_asr_dat_files.py [<id> <dat filepath> . . .]
#

import os
import sys
import re
from map_anc_2_anc import *
from argParser import ArgParser
ap = ArgParser(sys.argv)

anc1 = ap.getArg("--anc1")
nick1 = ap.getArg("--nick1")
msa1 = ap.getArg("--msa1")
seed1 = ap.getArg("--seed1")

anc2 = ap.getArg("--anc2")
nick2 = ap.getArg("--nick2")
msa2 = ap.getArg("--msa2")
seed2 = ap.getArg("--seed2")

runid = ap.getOptionalArg("--runid")
if runid == False:
    exit()

rsitesa = []
x = ap.getOptionalList("--restrict_sites_1")
if x != None:
Exemplo n.º 6
0
import os, sys
from argParser import ArgParser
ap = ArgParser(sys.argv)

gffpath = ap.getArg("--gff")
if False == os.path.exists(gffpath):
    print "\n. Error. I can't find your GFF at", gffpath
    exit()

bdgpath = ap.getArg("--bdg")
if bdgpath != False:
    if False == os.path.exists(bdgpath):
        print "\n. Error. I can't find your BDG at", bdgpath
        exit()

genename = ap.getArg("--genename")

regsize = int( ap.getArg("--regsize") )

chrom = None
start = None
stop = None
strand = None
fin = open(gffpath, "r")
for l in fin.xreadlines():
    if l.__len__() > 0 and False == l.startswith("#"):
        tokens = l.split()
        this_gene = tokens[8].split(";")[0].split("=")[1] # orfName 
        if this_gene == genename:
            chrom = tokens[0]
            start = int( tokens[3] )
Exemplo n.º 7
0
#
# Compare two *_trace_ files from PhyML, using different optimization algorithms or different models.
# Did the two searches explore similar regions of tree space?
#

import re,sys,os,pickle
from dendropy import Tree
from argParser import ArgParser
argParser = ArgParser(sys.argv)

t1path = sys.argv[1]
t2path = sys.argv[2]

t1trees = []
t2trees = []

HUGE = 100000000; # approaching infinity

colors = {}
colors["Multimax"] = "royalblue"
colors["Unimax"] = "orangered"
colors[1] = "black"
colors["UMtd"] = colors["Unimax"] 
colors["MMtd"] = colors["Multimax"] 

pch = {}
pch["Multimax"] = "15"
pch["Unimax"] = "15"
pch[1] = "15"
pch["UMtd"] = "17" 
pch["MMtd"] = "16"
Exemplo n.º 8
0
import os, sys
from argParser import ArgParser

ap = ArgParser(sys.argv)

gffpath = ap.getArg("--gff")
if False == os.path.exists(gffpath):
    print "\n. Error. I can't find your GFF at", gffpath
    exit()

bdgpath = ap.getArg("--bdg")
if bdgpath != False:
    if False == os.path.exists(bdgpath):
        print "\n. Error. I can't find your BDG at", bdgpath
        exit()

genename = ap.getArg("--genename")

regsize = int(ap.getArg("--regsize"))

chrom = None
start = None
stop = None
strand = None
fin = open(gffpath, "r")
for l in fin.xreadlines():
    if l.__len__() > 0 and False == l.startswith("#"):
        tokens = l.split()
        this_gene = tokens[8].split(";")[0].split("=")[1]  # orfName
        if this_gene == genename:
            chrom = tokens[0]
Exemplo n.º 9
0
#
# Create a master table of gene-peak occurances across multiple species and replicate conditions
#

import os, sys, re

from plot_venn import *

from argParser import ArgParser
ap = ArgParser(sys.argv)

runids = ap.getList("--runids") # a list of runid names
runid = ap.getArg("--runid") # the (output) runid for this peak comparison
pillarspath = ap.getArg("--pillars") # a file containing G
orf_names = {}

def splash():
    print "============================================"
    print "  compare_peaks.py"
    print "  Victor Hanson-Smith, 2014"
    print "  [email protected]"
    print "============================================"
    
splash()

def get_runid_reps():
    print "\n. Reading Replicates..."
    runid_reps = {}
    for t in runids:
        if t not in runid_reps:
            runid_reps[t] = []
Exemplo n.º 10
0
#
# This is the top-level script for the after_peaks part
# of the ChIP-Seq pipeline.
#
# This script is launched by the script after_illumina/run_distill.py,
# although you can also launch it on its own.
# 
#

from read_config import *
from chipseqdb import *
from chipseqdb_plots import *
from overlap_stats import *

from argParser import ArgParser
ap = ArgParser(sys.argv)

def splash():
    print "============================================================================"
    print "."
    print ". APRES: Analysis Pipeline for Replicate Experiments across Species."
    print "."
    print ". [Part of the ChIP-Seq Distillery Suite]"
    print "."
    print ". Last Updated January 2014"
    print "."
    print ". Written by Victor Hanson-Smith -- [email protected]"
    print "============================================================================="

#
# Build, or add to, the database
Exemplo n.º 11
0
 def setUp(self):
     args = ["--domain", "en", "--tile", "English"]
     self.argparse = ArgParser(args)
Exemplo n.º 12
0
 def setUp(self):
     args = ["--domain", "en", "--title", "engly", "-r"]
     self.argparse = ArgParser(args)
Exemplo n.º 13
0
#
# Draw a subsample of reads from a FASTQ file.
#
import sys, os
from argParser import ArgParser
ap = ArgParser(sys.argv)

inpath = ap.getArg("--in")
outpath = ap.getArg("--out")
n = int( ap.getArg("--n") ) 

fin = open(inpath, "r")
fout = open(outpath, "w")

count_reads = 0
lc = 0
for l in fin.xreadlines():
    if lc == 0:
        count_reads += 1

    if count_reads <= n:
        fout.write( l )
    else:
        break
    
    lc += 1
    if lc == 4:
        lc = 0
    
    if count_reads%10 == 0:
        sys.stdout.write("\r    --> %.1f%%" % (100*count_reads/float(n)) )
Exemplo n.º 14
0
#
# This script is for generating toy-sized test cases
#
# Subsample a track file, such as BDGs and BEDs
#

import sys, os
from argParser import ArgParser
ap = ArgParser(sys.argv)

bdgpath = ap.getArg("--in")
outpath = ap.getArg("--out") # output path of subsampled BDG

# Lines in the BDG that contain the keyword will be sampled.
# all other lines will be discarded
keyword = ap.getArg("--keyword")

fout = open(outpath, "w")

fin = open(bdgpath, "r")
for l in fin.xreadlines():
    if l.__contains__(keyword):
        fout.write( l )
fin.close()
fout.close()
Exemplo n.º 15
0
#################################################
#
# USAGE:
#
# python compare_asr_dat_files.py [<id> <dat filepath> . . .]
#

import os
import sys
import re
from map_anc_2_anc import *
from argParser import ArgParser
ap = ArgParser(sys.argv)

anc1 = ap.getArg("--anc1")
nick1 = ap.getArg("--nick1")
msa1 = ap.getArg("--msa1")
seed1 = ap.getArg("--seed1")

anc2 = ap.getArg("--anc2")
nick2 = ap.getArg("--nick2")
msa2 = ap.getArg("--msa2")
seed2 = ap.getArg("--seed2")

runid = ap.getOptionalArg("--runid")
if runid == False:
    exit()

rsitesa = []
x = ap.getOptionalList("--restrict_sites_1")
if x != None:
Exemplo n.º 16
0
import math
import os
import re
import sys

from argParser import ArgParser
argp = ArgParser(sys.argv)

spath = argp.getArg("--input")
fin = open( spath, "r" )
lines = fin.readlines()
fin.close()

output = argp.getArg("--output")

def plot_comb(cat):
    cranscript = "plot." + output + "." + cat.__str__() + ".cran"
    f = open(cranscript, "w")
 
    y = "y <- c("
    x = "x <- c("
    
    for site in site_pps:
        y += site_pps[site][cat].__str__() + ","
        x += site.__str__() + ","

    y = re.sub(",$", "", y)
    y += ")"
    f.write( y + "\n")  
    
    x = re.sub(",$", "", x)
Exemplo n.º 17
0
#
# run_distill.py
#
# This is the top-level script for the ChIP-Seq Analysis Pipeline.
# This script calls functions in other Python scripts included in this project.
#

import re, os, sys, time
from annotation_db import *
from config import *
from hybrid_tools import *
from tools import *
from html_tools import *
from argParser import ArgParser
ap = ArgParser(sys.argv)


def splash():
    print "======================================================================"
    print "."
    print ". The ChIP-Seq Distillery"
    print "."
    print ". A pipeline to process your FASTQ reads."
    print "."
    print ". Last Updated: May 2016"
    print "."
    print ". This program does the following steps:"
    print "\t. Maps reads to reference genome (bowtie)"
    print "\t. Separates reads from hybrid genomes (optional)"
    print "\t. Sorts all reads and creates BAM files (samtools)"
    print "\t. Finds peaks (macs2)"
Exemplo n.º 18
0
 def setUp(self):
     args = ["--title", "Rupert Sheldrake"]
     self.argparse = ArgParser(args)
Exemplo n.º 19
0
#
# This is the top-level script for the after_peaks part
# of the ChIP-Seq pipeline.
#
# This script is launched by the script after_illumina/run_distill.py,
# although you can also launch it on its own.
#
#

from read_config import *
from chipseqdb import *
from chipseqdb_plots import *
from overlap_stats import *

from argParser import ArgParser
ap = ArgParser(sys.argv)


def splash():
    print "============================================================================"
    print "."
    print ". APRES: Analysis Pipeline for Replicate Experiments across Species."
    print "."
    print ". [Part of the ChIP-Seq Distillery Suite]"
    print "."
    print ". Last Updated January 2014"
    print "."
    print ". Written by Victor Hanson-Smith -- [email protected]"
    print "============================================================================="

Exemplo n.º 20
0
 def setUp(self):
     args = ["--pageid", "en", "--domain", "en"]
     self.argparse = ArgParser(args)
Exemplo n.º 21
0
#
# Draw a subsample of reads from a FASTQ file.
#
import sys, os
from argParser import ArgParser
ap = ArgParser(sys.argv)

inpath = ap.getArg("--in")
outpath = ap.getArg("--out")
n = int(ap.getArg("--n"))

fin = open(inpath, "r")
fout = open(outpath, "w")

count_reads = 0
lc = 0
for l in fin.xreadlines():
    if lc == 0:
        count_reads += 1

    if count_reads <= n:
        fout.write(l)
    else:
        break

    lc += 1
    if lc == 4:
        lc = 0

    if count_reads % 10 == 0:
        sys.stdout.write("\r    --> %.1f%%" % (100 * count_reads / float(n)))
Exemplo n.º 22
0
 def setUp(self):
     args = ["--revid", "--domain", "en", "-v"]
     self.argparse = ArgParser(args)
Exemplo n.º 23
0
#
# method: bins all branch lengths into 0.05-sized bins and counts
# the proportion of BLs in each bin
#
# output: a CRAN script and a PDF plot (generated from the CRAN script)
#
#

import math
import os
import re
import sys
from dendropy import Tree

from argParser import ArgParser
argParser = ArgParser(sys.argv)

t1path = sys.argv[1]
t2path = sys.argv[2]
id = argParser.getOptionalArg("--id")
if id == False:
    id = ""

import numpy as np
import cogent.maths.stats.test as stats

colors = ["orangered","royalblue", "black"]
pch = [20,5,3]
COLORS = {}
COLORS["unimax"] = "tomato"
COLORS["multimax"] = "deepskyblue"
Exemplo n.º 24
0
 def setUp(self):
     args = ["-v", "000"]
     self.argparse = ArgParser(args)
Exemplo n.º 25
0
#
# method: bins all branch lengths into 0.05-sized bins and counts
# the proportion of BLs in each bin
#
# output: a CRAN script and a PDF plot (generated from the CRAN script)
#
#

import math
import os
import re
import sys
from dendropy import Tree

from argParser import ArgParser
argParser = ArgParser(sys.argv)

inpath = sys.argv[1]
id = sys.argv[2]

import numpy as np
import cogent.maths.stats.test as stats

colors = ["orangered", "royalblue", "black"]
pch = [20, 5, 3]
COLORS = {}
COLORS["unimax"] = "tomato"
COLORS["multimax"] = "deepskyblue"
COLORS["true"] = "black"
COLORS["bionj"] = "snow3"
Exemplo n.º 26
0
class Statue:

    def __init__(self, database_name, time_between_call, logger):
        self.Database = DatabaseManager(database_name)
        self.TimeBetweenCall = time_between_call
        self.Logger = logger
        self.Options = OptionValues(BadDragonApi(self.Logger))
        self.UserFilter = {}
        self.ToyInShop = {}
        self.Parser = ArgParser(self.Options)
        self.toy_from_database()
        self.TwitterThread = []

    def start(self):
        self.Logger.info('Start get api')

    def add_filter(self, new_filter, user_id):
        new_filter.save_in_database(self.Database, user_id)

    @staticmethod
    def option_from_type(value_id, option_type):
        if value_id in option_type:
            return option_type[value_id]
        return value_id

    def toy_from_database(self):
        """Sync the toy list with the toy in the database."""
        data = self.Database.get_toys()
        self.Logger.debug('Toy in database : {}'.format(data))
        dic = {}
        for toy in data:
            dic[toy[0]] = Toy(
                self.option_from_type(toy[1], self.Options.ProductName),
                self.option_from_type(toy[3], self.Options.ProductType),
                self.option_from_type(toy[2], self.Options.SizeOptions),
                toy[4],
                self.option_from_type(toy[5], self.Options.FirmnessOptions),
                self.option_from_type(toy[6], self.Options.CumTubValues),
                self.option_from_type(toy[7], self.Options.SuctionCupValues),
                self.option_from_type(toy[8], self.Options.FlopOption),
                toy[9], toy[0])
        self.ToyInShop = dic

    def delete_filter(self, user_id, filter_name):
        """Wrap delete a filter kn the database"""
        self.Database.remove_filter(user_id, filter_name)

    async def on_new_toy(self, new_list):
        """Notify all object for the new toy."""
        for user in self.UserFilter:
            await self.UserFilter[user].new_toy(new_list)

    def actualise_toy_name(self):
        # TODO
        """Actualise the toy name list and the help to help find the toy code"""

        self.Parser.set_toy_list(list(self.Options.ProductName.keys()))

    async def actualise_shop(self):
        """Get all toy actually in the shop and compare to the actual."""
        temp = self.get_toy()
        new = []
        for i in temp:
            if i not in self.ToyInShop:
                new.append(temp[i])
        self.ToyInShop = temp
        self.Logger.info("{} new toy and {} in total in shop".format(len(new), len(self.ToyInShop)))
        for_database = []
        actual_time = time.time()
        for i in temp.values():
            for_database.append((i.get_id(),
                                 None if i.get_name() is None else i.get_name().option_id(),
                                 None if i.get_size() is None else i.get_size().option_id(),
                                 None if i.get_type() is None else i.get_type().option_id(),
                                 i.get_color(),
                                 None if i.get_firmness() is None else i.get_firmness().option_id(),
                                 None if i.get_cum_tube() is None else i.get_cum_tube().option_id(),
                                 None if i.get_suction_cup() is None else i.get_suction_cup().option_id(),
                                 None if i.get_flop() is None else i.get_flop().option_id(),
                                 None if i.get_description() is None else i.get_description(),
                                 actual_time))
        self.Database.set_toy(for_database)
        await self.on_new_toy(new)

    def get_toy(self):
        """Get all the actual toy in clearance."""
        self.Logger.debug("Start to get the toys")
        temp = {}
        extract = BadDragonApi(self.Logger)
        self.actualise_toy_name()
        self.Logger.debug("Start to parse the toys")
        for i in range(0, extract.number_of_toy()):
            toy = extract.get_toy(i)
            if toy['sku'].lower() in self.Options.ProductName:
                temp[toy['id']] = Toy(
                    self.option_from_type(toy['sku'], self.Options.ProductName),
                    self.Options.ProductType[toy['sku'].lower()],
                    self.option_from_type(toy['size'], self.Options.SizeOptions),
                    self.option_from_type(toy['colorTheme']['name'] if toy['colorTheme'] else None,
                                          self.Options.ColorOptions),
                    self.option_from_type(toy['firmness'], self.Options.FirmnessOptions),
                    self.option_from_type(toy['cumtube'], self.Options.CumTubValues),
                    self.option_from_type(toy['suction_cup'], self.Options.SuctionCupValues),
                    self.option_from_type(toy['is_flop'], self.Options.FlopOption),
                    toy['external_flop_reason'], toy['id'])
            else:
                self.Logger.warning("Error {} is not in the dictionary".format(toy['sku']))
        self.Logger.info("Get {} toy in stock".format(len(temp)))
        return temp

    def user_in(self, user):
        return user in self.UserFilter

    def add_user(self, user):
        if not self.user_in(user):
            self.UserFilter[user] = client.Client(user, self.Logger, self, self.Parser, self.ToyInShop)

    async def on_tweet(self):
        """When a tweet from bad-dragon is posted."""
        self.Logger.info("New tweet")
        await self.actualise_shop()

    async def on_time(self):
        """When the clock ring."""
        self.Logger.info("On Time Scan")
        await self.actualise_shop()
Exemplo n.º 27
0
"""

tab2gff.py

Victor Hanson-Smith
[email protected]

This script converts TAB-formatted genome annotations into
GFF-formatted genome feature files.
"""

import sys, os
from argParser import ArgParser
ap = ArgParser(sys.argv)

#if sys.argv.__len__() < 3

def int2roman(x):
    if x == 0:
        return 0
    if x == 1:
        return "I"
    if x == 2:
        return "II"
    if x == 3:
        return "III"
    if x == 4:
        return "IV"
    if x == 5:
        return "V"
    if x == 6:
Exemplo n.º 28
0
#
# run_distill.py
#
# This is the top-level script for the ChIP-Seq Analysis Pipeline.
# This script calls functions in other Python scripts included in this project.
#

import re, os, sys, time
from annotation_db import *
from config import *
from hybrid_tools import *
from tools import *
from html_tools import *
from argParser import ArgParser
ap = ArgParser(sys.argv)

def splash():
    print "======================================================================"
    print "."
    print ". The ChIP-Seq Distillery"
    print "."
    print ". A pipeline to process your FASTQ reads."
    print "."
    print ". Last Updated: May 2016"
    print "."
    print ". This program does the following steps:"
    print "\t. Maps reads to reference genome (bowtie)"
    print "\t. Separates reads from hybrid genomes (optional)"
    print "\t. Sorts all reads and creates BAM files (samtools)"
    print "\t. Finds peaks (macs2)"
    print "\t. Calculates fold-enrichment (macs2)"
Exemplo n.º 29
0
#!/usr/bin/env python3

import re
import os
import glob
import sys
from argParser import ArgParser

f = open('/dev/null', 'w')
sys.stderr = f
parser = ArgParser()
sys.exit(0)
Exemplo n.º 30
0

def test(doc):
    print([(w.text, w.pos_) for w in doc])

    for token in doc:
        print(token.text, token.lemma_, token.pos_, token.tag_, token.dep_,
              token.shape_, token.is_alpha, token.is_stop)

    print("----")
    for ent in doc.ents:
        print(ent.text, ent.start_char, ent.end_char, ent.label_)
    return doc


txt = "Capgemini har kontor på Sirkus Shopping, Falkenborgveien 9"

if __name__ == '__main__':
    args = ArgParser('SpaCy args')
    language = args.get_lang()

    conf = Config(language)
    if not conf.data:
        sys.exit(0)

    models = conf.get_models()
    views = ["parser", "ner", "textcat", "similarity", "tokens"]

    viz = Viz(conf.get_models(), views)
    viz.show(txt)
Exemplo n.º 31
0
from Bio import SeqIO

from chipseqdb import *
from chipseqdb_api import *

from argParser import ArgParser
ap = ArgParser(sys.argv)

from plot_scatter import *

"""Jump allows for some steps to be skipped."""
jump = ap.getOptionalArg("--jump")
stop = ap.getOptionalArg("--stop")
if jump == False:
    jump = 0
else:
    jump = float(jump)
    
if stop == False:
    stop = 10000000
else:
    stop = float(stop)

def read_motifs(motif_path):
    """Reads PSWM data from a text file.
    Motifs are expected to look like this:
    
    /NAME=[SWISS] ABF1 TYPE=PSFM SPECIES=S.cer
    0.208782    0.155386    0.135415    0.500414
    0.745936    0.0    0.254063    0.0
    0.0    0.0    0.0    1.0
Exemplo n.º 32
0
#
# This script is for generating toy-sized test cases
#
# Subsample a track file, such as BDGs and BEDs
#

import sys, os
from argParser import ArgParser
ap = ArgParser(sys.argv)

bdgpath = ap.getArg("--in")
outpath = ap.getArg("--out")  # output path of subsampled BDG

# Lines in the BDG that contain the keyword will be sampled.
# all other lines will be discarded
keyword = ap.getArg("--keyword")

fout = open(outpath, "w")

fin = open(bdgpath, "r")
for l in fin.xreadlines():
    if l.__contains__(keyword):
        fout.write(l)
fin.close()
fout.close()