Exemplo n.º 1
0
    def run(self, args):
        if not args.index.endswith(".gem"):
            raise CommandException("No valid GEM index specified, the file has to end in .gem")
        if not os.path.exists(args.index):
            raise CommandException("GEM index not found")
        if not os.path.exists(args.annotation):
            raise CommandException("Annotation not found")

        name = args.name
        if name is None:
            name = os.path.basename(args.annotation)

        junctions_out = name + ".junctions"
        index_out = name + ".junctions.gem"

        print "Loading Junctions"
        junctions = set(gem.junctions.from_gtf(args.annotation))
        print "%d Junctions loaded from annotation " % (len(junctions))
        gem.junctions.write_junctions(junctions, junctions_out)
        print "Junctions writen to %s " % (junctions_out)

        print "Computing transcriptome..."
        (transcriptome, keys) = gem.compute_transcriptome(args.maxlength, args.index, junctions_out)

        print "Indexing transcriptome"
        gem.index(transcriptome, index_out, threads=args.threads)
        print "Done"
Exemplo n.º 2
0
    def run(self, args):
        if not args.index.endswith(".gem"):
            raise CommandException("No valid GEM index specified, the file has to end in .gem")
        if not os.path.exists(args.index):
            raise CommandException("GEM index not found")
        if not os.path.exists(args.annotation):
            raise CommandException("Annotation not found")

        name = args.name
        if name is None:
            name = os.path.basename(args.annotation)

        junctions_out = name + ".junctions"
        index_out = name + ".junctions.gem"

        print "Loading Junctions"
        junctions = set(gem.junctions.from_gtf(args.annotation))
        print "%d Junctions loaded from annotation " % (len(junctions))
        gem.junctions.write_junctions(junctions, junctions_out)
        print "Junctions writen to %s " % (junctions_out)

        print "Computing transcriptome..."
        (transcriptome, keys) = gem.compute_transcriptome(args.maxlength, args.index, junctions_out)

        print "Indexing transcriptome"
        gem.index(transcriptome, index_out, threads=args.threads)
        print "Done"
Exemplo n.º 3
0
    def run(self, args):
        input = args.input
        output = os.path.basename(input)
        if args.output is not None:
            output = args.output
        else:
            output = output[:output.rfind(".")] + ".gem"
        if not output.endswith(".gem"):
            raise CommandException("Output file name has to end in .gem")
        if not os.path.exists(input):
            raise CommandException("Input file not found : %s" % input)
        if input.endswith(".gz"):
            raise CommandException("Compressed input is currently not supported!")

        logging.gemtools.gt("Creating index")
        gem.index(input, output, threads=args.threads)
Exemplo n.º 4
0
def test_indexer_output_suffix():
    result = results_dir + "/genome_index.gem"
    input = testfiles["genome.fa"]
    index = gem.index(input, result)
    assert index == result, "Result should be %s.gem but is %s" % (result,
                                                                   index)
    assert os.path.exists(result)
Exemplo n.º 5
0
def test_junction_filter():
    result = results_dir + "/test_xs.gem"
    index = gem.index(testfiles["test_xs.fa"], result)
    jf = gem.splits.append_xs_filter(index)
    of = open(testfiles["test_xs.sam"])

    def get_xs(l):
        for f in l.split("\t"):
            if f.startswith("XS"):
                return f[-1]
        return None

    for line in of:
        if line[0] == "@": continue
        source_xs = get_xs(line)
        filter_xs = get_xs(jf.filter(line))
        assert source_xs == filter_xs
Exemplo n.º 6
0
#!/usr/bin/python
"""Example script that creates the example gem-index"""

import gem
import os

if __name__ == "__main__":
    basedir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
    target = "%s/results/chr21.gem" % basedir
    source = "%s/data/chr21.fa" % basedir
    print("Creating index for %s" % (source))
    print("GEM index is created in %s" % (target))

    if not os.path.exists(source):
        print("Unable to find source file %s. "
              "Please make sure you ran the bootstrap "
              "script to download and prepare demo data" % (source))
        exit(1)
    index = gem.index(source, target)
    print("Created index %s " % index)


Exemplo n.º 7
0
def test_indexer_output_suffix():
    result = results_dir + "/genome_index.gem"
    input = testfiles["genome.fa"]
    index = gem.index(input, result)
    assert index == result, "Result should be %s.gem but is %s" % (result, index)
    assert os.path.exists(result)
Exemplo n.º 8
0
def test_indexer():
    result = results_dir + "/genome_index"
    input = testfiles["genome.fa"]
    index = gem.index(input, result)
    assert index == result+".gem"
    assert os.path.exists(result+".gem")
def create_index():
    """Create the example index"""
    print "Preparing index"
    return gem.index("%s/chr21.fa" % data_dir, "%s/chr21.gem" % result_dir, threads=THREADS)
Exemplo n.º 10
0
def test_indexer():
    result = results_dir + "/genome_index"
    input = testfiles["genome.fa"]
    index = gem.index(input, result)
    assert index == result + ".gem"
    assert os.path.exists(result + ".gem")