Exemplo n.º 1
0
def test_example_data_md5s():
    data_dir = helpers.data_dir()

    data = [
        i.strip().split() for i in '''
    3735b696b3a416a59f8755eaf5664e5a  sine-hg38-0.bedgraph.bw
    73ad8ba3590d0895810d069599b0e443  sine-hg38-1.bedgraph.bw
    85478d1ecc5906405ccb43d1ca426d29  sine-hg38-2.bedgraph.bw
    55ac2603c31b232dacfdaba07d8a25eb  sine-no1-1000.bedgraph.bw
    b8c983862c58fee6afa99382634ab2d8  sine-no1-100.bedgraph.bw
    35fa6ac3453e2bbd503c40a1d15afc65  random-hg38-0.bigBed
    3c94c294f8376f625f3701dee7641997  random-hg38-1.bigBed
    3bed0726e452d677f33979b2ed1c65d6  random-hg38-2.bigBed
    72934b760f1f5ee8f99d596536ef8b4c  random-no1-0.bigBed
    19116a3295e5679cb79ffc8904fa5abe  random-no1-1.bigBed
    d628cd0d3b91d8426bb9d0f99b39be52  random-no1-2.bigBed
    '''.splitlines(False)
        if not i.strip().startswith('#') and len(i.strip()) > 0
    ]

    # for some reason, only faToTwoBit under py27 results in a different md5 than under py3.
    if sys.version_info[0] == 3:
        data.append(('ba2fd8b22bcad65bb6583da937ff5222', 'newOrg1.2bit'))

    success = True
    for md5, fn in data:
        fn = os.path.join(data_dir, fn)
        obs = hashlib.md5(open(fn, 'rb').read()).hexdigest()
        success = success and (obs == md5)
        print(obs, md5, fn)
    assert success
Exemplo n.º 2
0
def test_example_data_md5s():
    data_dir = helpers.data_dir()

    data = [i.strip().split() for i in '''
    3735b696b3a416a59f8755eaf5664e5a  sine-hg38-0.bedgraph.bw
    73ad8ba3590d0895810d069599b0e443  sine-hg38-1.bedgraph.bw
    85478d1ecc5906405ccb43d1ca426d29  sine-hg38-2.bedgraph.bw
    55ac2603c31b232dacfdaba07d8a25eb  sine-no1-1000.bedgraph.bw
    b8c983862c58fee6afa99382634ab2d8  sine-no1-100.bedgraph.bw
    35fa6ac3453e2bbd503c40a1d15afc65  random-hg38-0.bigBed
    3c94c294f8376f625f3701dee7641997  random-hg38-1.bigBed
    3bed0726e452d677f33979b2ed1c65d6  random-hg38-2.bigBed
    72934b760f1f5ee8f99d596536ef8b4c  random-no1-0.bigBed
    19116a3295e5679cb79ffc8904fa5abe  random-no1-1.bigBed
    d628cd0d3b91d8426bb9d0f99b39be52  random-no1-2.bigBed
    '''.splitlines(False) if not i.strip().startswith('#') and len(i.strip()) > 0]

    # for some reason, only faToTwoBit under py27 results in a different md5 than under py3.
    if sys.version_info[0] == 3:
        data.append(('ba2fd8b22bcad65bb6583da937ff5222', 'newOrg1.2bit'))

    success = True
    for md5, fn in data:
        fn = os.path.join(data_dir, fn)
        obs = hashlib.md5(open(fn, 'rb').read()).hexdigest()
        success = success and (obs == md5)
        print(obs, md5, fn)
    assert success
Exemplo n.º 3
0
import os
import subprocess
import pybedtools
from trackhub import helpers

data_dir = helpers.data_dir()

chromsizes = pybedtools.genome_registry.dm3.euchromatic
g = pybedtools.chromsizes_to_file(chromsizes)

# Make some randomized bigBed files
for i in range(3):
    x = (
        pybedtools.BedTool("chr2L 0 10000000", from_string=True)
        .window_maker(g=g, w=1000 * (i + 1))
        .shuffle(g=g, seed=i)
        .sort()
    )

    out = os.path.join(data_dir, "random-dm3-%s.bigBed" % i)

    cmds = ["bedToBigBed", x.fn, g, out]
    p = subprocess.Popen(cmds)
    p.communicate()


# make some sine waves for bigWigs
import numpy as np


def sine(factor):
Exemplo n.º 4
0
import os
from textwrap import dedent
import warnings
import pytest
import tempfile
from trackhub import upload
from trackhub.helpers import data_dir
from trackhub import Hub, GenomesFile, Genome, Track, CompositeTrack, \
    TrackDb, ViewTrack, SuperTrack, AggregateTrack

d = data_dir()

class TestUpload(object):
    def setup(self):
        with pytest.warns(DeprecationWarning):
            self.hub = Hub(
                hub='example_hub',
                short_label='example hub',
                long_label='an example hub for testing',
                email='*****@*****.**')
            self.genomes_file = GenomesFile()
            self.genome = Genome('dm3')
            self.trackdb = TrackDb()

            self.tracks = [
                Track(
                    name='track1',
                    tracktype='bigBed',
                    local_fn=os.path.join(d, 'random-hg38-0.bigBed'),
                    remote_fn='1.bigbed',
                ),
Exemplo n.º 5
0
import os
import random
import subprocess
from collections import OrderedDict
import pybedtools
import numpy as np
from trackhub import helpers

random.seed(0)
np.random.seed(0)

data_dir = helpers.data_dir()

chromsizes = OrderedDict([("chr1", (0, 100000)), ("chr2", (0, 75000)),
                          ("chr3", (0, 50000))])


def random_dna(length, chars="ATGC"):
    return ''.join(random.choice(chars) for _ in range(length)) + "\n"


fasta = open(os.path.join(data_dir, "newOrg1.fa"), "w")

for chrom, size in chromsizes.items():
    fasta.write(">" + chrom + "\n")
    n, r = divmod(size[1], 80)
    for _ in range(n):
        fasta.write(random_dna(80))
    fasta.write(random_dna(r))

cmds = ["faToTwoBit", fasta.name, fasta.name[0:-2] + "2bit"]
Exemplo n.º 6
0
import os
from textwrap import dedent
import pytest
import tempfile
from trackhub import upload
from trackhub.helpers import data_dir
from trackhub import Hub, GenomesFile, Genome, Track, CompositeTrack, \
    TrackDb, ViewTrack, SuperTrack, AggregateTrack

d = data_dir()

class TestUpload(object):
    def setup(self):
        self.hub = Hub(
            hub='example_hub',
            short_label='example hub',
            long_label='an example hub for testing',
            email='*****@*****.**')
        self.genomes_file = GenomesFile()
        self.genome = Genome('dm3')
        self.trackdb = TrackDb()

        self.tracks = [
            Track(
                name='track1',
                tracktype='bigBed',
                source=os.path.join(d, 'random-hg38-0.bigBed')
            ),
            Track(
                name='track2',
                tracktype='bigWig',