本文整理汇总了Python中pybedtools.example_filename函数的典型用法代码示例。如果您正苦于以下问题:Python example_filename函数的具体用法?Python example_filename怎么用?Python example_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了example_filename函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bed_methods
def test_bed_methods():
"""
Generator that yields tests, inserting different versions of `bed` as needed
"""
for method, send_kwargs, expected in parse_yaml(config_fn):
ignore = ['a', 'b','abam','i']
skip_test = False
for i in ignore:
if i in send_kwargs:
skip_test = True
if skip_test:
continue
if 'bed' not in send_kwargs:
continue
if 'files' in send_kwargs:
send_kwargs['files'] = [pybedtools.example_filename(i) for i in send_kwargs['files']]
if 'bams' in send_kwargs:
send_kwargs['bams'] = [pybedtools.example_filename(i) for i in send_kwargs['bams']]
if 'fi' in send_kwargs:
send_kwargs['fi'] = pybedtools.example_filename(send_kwargs['fi'])
orig_bed = pybedtools.example_bedtool(send_kwargs['bed'])
del send_kwargs['bed']
done = []
for kind_bed in ('filename', 'generator', 'stream', 'gzip'):
bed = converter[kind_bed](orig_bed)
kind = 'i=%(kind_bed)s' % locals()
f = partial(run, method, bed, expected, **send_kwargs)
f.description = '%(method)s, %(kind)s, %(send_kwargs)s' % locals()
yield (f, )
开发者ID:PanosFirmpas,项目名称:pybedtools,代码行数:35,代码来源:test_iter.py
示例2: test_intron_exon_reads
def test_intron_exon_reads():
gff = pybedtools.example_filename('gdc.gff')
bam = pybedtools.example_filename('gdc.bam')
cmds = [
'intron_exon_reads.py',
'--gff', gff, '--bam', bam, '--processes', '2']
out = sp.check_output(cmds, universal_newlines=True)
assert out == dedent(
"""\
exon_only 3
intron_only 3
intron_and_exon 1
""")
cmds = [
'intron_exon_reads.py',
'--gff', gff, '--bam', bam, '--processes', '2', '--stranded']
out = sp.check_output(cmds, universal_newlines=True)
assert out == dedent(
"""\
exon_only 0
intron_only 0
intron_and_exon 0
""")
开发者ID:daler,项目名称:pybedtools,代码行数:25,代码来源:test_scripts.py
示例3: main
def main():
ap = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('--bed', help='BED file of e.g. peaks')
ap.add_argument('--gff', help='GFF file of e.g. annotations')
ap.add_argument('--out', default='out.png', help='Output PNG file')
ap.add_argument('--stranded', action='store_true',
help='Use strand-specific intersections')
ap.add_argument('--include', nargs='*', help='Featuretypes to include')
ap.add_argument('--exclude', nargs='*', help='Featuretypes to exclude')
ap.add_argument('--thresh', type=float, help='Threshold percentage below which output will be suppressed')
ap.add_argument('--test', action='store_true',
help='Run test, overwriting all other args')
args = ap.parse_args()
if not args.test:
if args.include and args.exclude:
raise ValueError('Cannot specify both --include and --exclude')
make_pie(bed=args.bed,
gff=args.gff,
out=args.out,
thresh=args.thresh,
stranded=args.stranded,
include=args.include,
exclude=args.exclude)
else:
make_pie(bed=pybedtools.example_filename('gdc.bed'),
gff=pybedtools.example_filename('gdc.gff'),
stranded=True,
out='out.png',
include=['CDS',
'intron',
'five_prime_UTR',
'three_prime_UTR'])
开发者ID:Fabrices,项目名称:pybedtools,代码行数:35,代码来源:peak_pie.py
示例4: test_isBAM
def test_isBAM():
bam = pybedtools.example_filename('x.bam')
notabam = pybedtools.example_filename('a.bed')
open('tiny.txt', 'w').close()
assert pybedtools.helpers.isBAM(bam)
assert not pybedtools.helpers.isBAM(notabam)
assert not pybedtools.helpers.isBAM('tiny.txt')
os.unlink('tiny.txt')
开发者ID:Fabrices,项目名称:pybedtools,代码行数:8,代码来源:test_helpers.py
示例5: test_issue_156
def test_issue_156():
# NOTE: this isn't appropriate for including in the test_iter cases, since
# that tests filenames, gzipped files, and iterators. There's no support
# for "list of iterators" as the `b` argument. Plus, here we're not
# concerned with the ability to handle those different input types -- just
# that lists of filenames works.
a = pybedtools.example_bedtool('a.bed')
b = [pybedtools.example_filename('b.bed'),
pybedtools.example_filename('c.gff')]
res = str(a.intersect(b))
assert res == fix(
"""
chr1 59 100 feature1 0 +
chr1 155 200 feature2 0 +
chr1 173 200 feature2 0 +
chr1 173 200 feature2 0 +
chr1 100 200 feature2 0 +
chr1 155 200 feature3 0 -
chr1 464 500 feature3 0 -
chr1 485 500 feature3 0 -
chr1 173 326 feature3 0 -
chr1 438 500 feature3 0 -
chr1 495 500 feature3 0 -
chr1 485 500 feature3 0 -
chr1 173 326 feature3 0 -
chr1 438 500 feature3 0 -
chr1 150 269 feature3 0 -
chr1 900 901 feature4 0 +
chr1 900 913 feature4 0 +
chr1 900 913 feature4 0 +
chr1 900 950 feature4 0 +
"""), res
res = str(a.intersect(b, wb=True, names=['B', 'C']))
assert res == fix(
"""
chr1 59 100 feature1 0 + C chr1 ucb gene 60 269 . - . ID=thaliana_1_6160_6269;match=fgenesh1_pg.C_scaffold_1000119;rname=thaliana_1_6160_6269
chr1 155 200 feature2 0 + B chr1 155 200 feature5 0 -
chr1 173 200 feature2 0 + C chr1 ucb CDS 174 326 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
chr1 173 200 feature2 0 + C chr1 ucb mRNA 174 326 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 100 200 feature2 0 + C chr1 ucb gene 60 269 . - . ID=thaliana_1_6160_6269;match=fgenesh1_pg.C_scaffold_1000119;rname=thaliana_1_6160_6269
chr1 155 200 feature3 0 - B chr1 155 200 feature5 0 -
chr1 464 500 feature3 0 - C chr1 ucb gene 465 805 . + . ID=thaliana_1_465_805;match=scaffold_801404.1;rname=thaliana_1_465_805
chr1 485 500 feature3 0 - C chr1 ucb CDS 486 605 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
chr1 173 326 feature3 0 - C chr1 ucb CDS 174 326 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
chr1 438 500 feature3 0 - C chr1 ucb CDS 439 630 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
chr1 495 500 feature3 0 - C chr1 ucb mRNA 496 576 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 485 500 feature3 0 - C chr1 ucb mRNA 486 605 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 173 326 feature3 0 - C chr1 ucb mRNA 174 326 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 438 500 feature3 0 - C chr1 ucb mRNA 439 899 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 150 269 feature3 0 - C chr1 ucb gene 60 269 . - . ID=thaliana_1_6160_6269;match=fgenesh1_pg.C_scaffold_1000119;rname=thaliana_1_6160_6269
chr1 900 901 feature4 0 + B chr1 800 901 feature6 0 +
chr1 900 913 feature4 0 + C chr1 ucb mRNA 631 913 . + . ID=AT1G01010.mRNA;Parent=AT1G01010;rname=AT1G01010
chr1 900 913 feature4 0 + C chr1 ucb CDS 760 913 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
chr1 900 950 feature4 0 + C chr1 ucb CDS 706 1095 . + . Parent=AT1G01010.mRNA;rname=AT1G01010
"""), res
开发者ID:daler,项目名称:pybedtools,代码行数:56,代码来源:test_issues.py
示例6: test_gzipped_files_can_be_intersected
def test_gzipped_files_can_be_intersected():
agz = _make_temporary_gzip(pybedtools.example_filename('a.bed'))
bgz = _make_temporary_gzip(pybedtools.example_filename('b.bed'))
agz = pybedtools.BedTool(agz)
bgz = pybedtools.BedTool(bgz)
a = pybedtools.example_bedtool('a.bed')
b = pybedtools.example_bedtool('b.bed')
assert a.intersect(b) == agz.intersect(bgz) == a.intersect(bgz) == agz.intersect(b)
开发者ID:PanosFirmpas,项目名称:pybedtools,代码行数:10,代码来源:test_gzip_support.py
示例7: test_gzip
def test_gzip():
# make new gzipped files on the fly
agz = pybedtools.BedTool._tmp()
bgz = pybedtools.BedTool._tmp()
os.system('gzip -c %s > %s' % (pybedtools.example_filename('a.bed'), agz))
os.system('gzip -c %s > %s' % (pybedtools.example_filename('b.bed'), bgz))
agz = pybedtools.BedTool(agz)
bgz = pybedtools.BedTool(bgz)
assert agz.file_type == bgz.file_type == 'bed'
a = pybedtools.example_bedtool('a.bed')
b = pybedtools.example_bedtool('b.bed')
assert a.intersect(b) == agz.intersect(bgz) == a.intersect(bgz) == agz.intersect(b)
开发者ID:ml4wc,项目名称:pybedtools,代码行数:12,代码来源:test1.py
示例8: test_links
def test_links():
# have to be careful about the path, since it is embedded in the HTML
# output -- so make a copy of the example file, and delete when done.
os.system('cp %s a.links.bed' % pybedtools.example_filename('a.bed'))
a = pybedtools.BedTool('a.links.bed')
a = a.links()
exp = open(pybedtools.example_filename('a.links.html')).read()
obs = open(a.links_html).read()
print exp
print obs
assert exp == obs
os.unlink('a.links.bed')
开发者ID:ml4wc,项目名称:pybedtools,代码行数:12,代码来源:test1.py
示例9: test_issue_218
def test_issue_218():
from pybedtools.helpers import set_bedtools_path, get_bedtools_path
from pybedtools import BedTool
orig_path = get_bedtools_path()
# As pointed out in #222, example_bedtool behaves differently from BedTool.
# example_bedtool is defined in pybedtools.bedtool but pybedtools.BedTool
# is imported in pybedtools.__init__. So check various constructors here.
for constructor in (
lambda x: pybedtools.example_bedtool(x),
lambda x: pybedtools.BedTool(pybedtools.example_filename(x)),
lambda x: pybedtools.bedtool.BedTool(pybedtools.example_filename(x)),
# NOTE: we likely need recursive reloading (like IPython.deepreload)
# for this to work:
#
# lambda x: BedTool(pybedtools.example_filename(x)),
):
x = constructor('x.bed')
x.sort()
assert "Original BEDTools help" in pybedtools.bedtool.BedTool.sort.__doc__
assert "Original BEDTools help" in x.sort.__doc__
set_bedtools_path('nonexistent')
# Calling BEDTools with non-existent path, but the docstring should not
# have been changed.
with pytest.raises(OSError):
x.sort()
assert "Original BEDTools help" in x.sort.__doc__
# The class's docstring should have been reset though.
assert pybedtools.bedtool.BedTool.sort.__doc__ is None
# Creating a new BedTool object now that bedtools is not on the path
# should detect that, adding a method that raises
# NotImplementedError...
y = constructor('x.bed')
with pytest.raises(NotImplementedError):
y.sort()
# ...and correspondingly no docstring
assert y.sort.__doc__ is None
assert pybedtools.bedtool.BedTool.sort.__doc__ is None
# Reset the path, and ensure the resetting works
set_bedtools_path()
z = constructor('x.bed')
z.sort()
开发者ID:daler,项目名称:pybedtools,代码行数:51,代码来源:test_issues.py
示例10: test_issue_178
def test_issue_178():
# Compatibility between py2/py3: py27 does not have FileNotFoundError, so
# set it to IOError (which does exist) for this function.
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError
try:
fn = pybedtools.example_filename('gdc.othersort.bam')
pybedtools.contrib.bigwig.bam_to_bigwig(fn, genome='dm3', output='tmp.bw')
x = pybedtools.contrib.bigwig.bigwig_to_bedgraph('tmp.bw')
assert x == fix(
'''
chr2L 70 75 1
chr2L 140 145 1
chr2L 150 155 1
chr2L 160 165 1
chr2L 210 215 1
chrX 10 15 1
chrX 70 75 1
chrX 140 145 1
''')
os.unlink('tmp.bw')
# If bedGraphToBigWig is not on the path, see
# https://github.com/daler/pybedtools/issues/227
except FileNotFoundError:
pass
开发者ID:daler,项目名称:pybedtools,代码行数:29,代码来源:test_issues.py
示例11: test_gzipped_files_are_iterable_as_normal
def test_gzipped_files_are_iterable_as_normal():
agz = _make_temporary_gzip(pybedtools.example_filename('a.bed'))
agz = pybedtools.BedTool(agz)
a = pybedtools.example_bedtool('a.bed')
for i in agz:
print(i)
assert_list_equal(list(a), list(agz))
开发者ID:PanosFirmpas,项目名称:pybedtools,代码行数:7,代码来源:test_gzip_support.py
示例12: test_cat
def test_cat():
a = pybedtools.example_bedtool('a.bed')
b = pybedtools.example_bedtool('b.bed')
b_fn = pybedtools.example_filename('b.bed')
assert a.cat(b) == a.cat(b_fn)
expected = fix("""
chr1 1 500
chr1 800 950
""")
assert a.cat(b) == expected
a = pybedtools.example_bedtool('a.bed')
b = pybedtools.example_bedtool('b.bed')
c = a.cat(b, postmerge=False)
assert len(a) + len(b) == len(c), (len(a), len(b), len(c))
print c
assert c == fix("""
chr1 1 100 feature1 0 +
chr1 100 200 feature2 0 +
chr1 150 500 feature3 0 -
chr1 900 950 feature4 0 +
chr1 155 200 feature5 0 -
chr1 800 901 feature6 0 +
""")
开发者ID:ml4wc,项目名称:pybedtools,代码行数:25,代码来源:test1.py
示例13: test_getting_example_beds
def test_getting_example_beds():
assert 'a.bed' in pybedtools.list_example_files()
a_fn = pybedtools.example_filename('a.bed')
assert a_fn == os.path.join(testdir, 'data', 'a.bed')
a = pybedtools.example_bedtool('a.bed')
assert a.fn == os.path.join(testdir, 'data', 'a.bed')
# complain appropriately if nonexistent paths are asked for
e = FileNotFoundError if six.PY3 else ValueError
with pytest.raises(e):
pybedtools.example_filename('nonexistent')
with pytest.raises(e):
pybedtools.example_bedtool('nonexistent')
with pytest.raises(e):
pybedtools.set_tempdir('nonexistent')
开发者ID:daler,项目名称:pybedtools,代码行数:17,代码来源:test_helpers.py
示例14: main
def main():
"""
Make a pie chart of features overlapping annotations (e.g., peaks in
introns, exons, etc)
"""
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--bed", help="BED file of e.g. peaks")
ap.add_argument("--gff", help="GFF file of e.g. annotations")
ap.add_argument("--out", default="out.png", help="Output PNG file")
ap.add_argument("--stranded", action="store_true", help="Use strand-specific intersections")
ap.add_argument("--include", nargs="*", help="Featuretypes to include")
ap.add_argument("--exclude", nargs="*", help="Featuretypes to exclude")
ap.add_argument("--thresh", type=float, help="Threshold percentage below which output will be " "suppressed")
ap.add_argument(
"--test",
action="store_true",
help="Run test, overwriting all other args. Result will " 'be "out.png" in current directory.',
)
args = ap.parse_args()
if not (args.bed and args.gff) and not args.test:
ap.print_help()
sys.exit(1)
if not args.test:
if args.include and args.exclude:
raise ValueError("Cannot specify both --include and --exclude")
make_pie(
bed=args.bed,
gff=args.gff,
out=args.out,
thresh=args.thresh,
stranded=args.stranded,
include=args.include,
exclude=args.exclude,
)
else:
make_pie(
bed=pybedtools.example_filename("gdc.bed"),
gff=pybedtools.example_filename("gdc.gff"),
stranded=True,
out="out.png",
include=["exon", "CDS", "intron", "five_prime_UTR", "three_prime_UTR"],
)
开发者ID:olgabot,项目名称:pybedtools,代码行数:45,代码来源:peak_pie.py
示例15: _classifier
def _classifier():
c = Classifier(
bed=pybedtools.example_filename('gdc.bed'),
annotations=pybedtools.example_filename('gdc.gff'))
c.classify()
bed = pybedtools.example_bedtool('gdc.bed')
assert c.class_counts == {
frozenset(['UTR', 'exon', 'mRNA', 'CDS', 'tRNA', 'gene']): 1,
frozenset(['intron', 'gene', 'mRNA']): 3,
frozenset([]): 1,
frozenset(['gene', 'exon', 'mRNA', 'CDS']): 2,
frozenset(['exon', 'mRNA', 'CDS', 'tRNA', 'intron', 'gene']): 1}
assert c.feature_classes == {
bed[0]: set(['.']),
bed[1]: set(['gene', 'exon', 'mRNA', 'CDS']),
bed[2]: set(['intron', 'gene', 'mRNA']),
bed[3]: set(['intron', 'gene', 'mRNA']),
bed[4]: set(['tRNA', 'UTR', 'exon', 'mRNA', 'CDS', 'gene']),
bed[5]: set(['gene', 'exon', 'mRNA', 'CDS']),
bed[6]: set(['intron', 'gene', 'mRNA']),
bed[7]: set(['tRNA', 'intron', 'exon', 'mRNA', 'CDS', 'gene']),
}
print('use these indexes for debugging')
for i, f in enumerate(bed):
print(i, f)
for k, v in list(c.class_features.items()):
print(k)
for i in v:
print('\t' + str(i))
assert c.class_features == {
frozenset([]): [bed[0]],
frozenset(['intron', 'gene', 'mRNA']): [bed[6], bed[2], bed[3]],
frozenset(['gene', 'exon', 'mRNA', 'CDS']): [bed[5], bed[1]],
frozenset(['UTR', 'exon', 'mRNA', 'CDS', 'tRNA', 'gene']): [bed[4]],
frozenset(['exon', 'mRNA', 'CDS', 'tRNA', 'intron', 'gene']): [bed[7]],
}
开发者ID:PanosFirmpas,项目名称:pybedtools,代码行数:43,代码来源:test_contrib.py
示例16: _get_sequence
def _get_sequence(chrom, pos, strand, genome):
a = pybedtools.BedTool("{0}\t{1}\t{2}\t.\t.\t{3}".format(chrom, pos-150, pos+150, strand), from_string=True)
fasta = pybedtools.example_filename(genome)
a = a.sequence(fi=fasta,s=True)
seq = open(a.seqfn).read().split("\n")
pre = seq[1][:150]
nt = seq[1][150]
post = seq[1][151:]
# print [pre, nt, post]
return [chrom , str(pos), "%s-%s-%s" % (pre, nt, post)]
开发者ID:hbc,项目名称:mammoth_code,代码行数:10,代码来源:mammoth-run.py
示例17: _classifier
def _classifier():
c = Classifier(bed=pybedtools.example_filename("gdc.bed"), annotations=pybedtools.example_filename("gdc.gff"))
c.classify()
bed = pybedtools.example_bedtool("gdc.bed")
assert c.class_counts == {
frozenset(["UTR", "exon", "mRNA", "CDS", "tRNA", "gene"]): 1,
frozenset(["intron", "gene", "mRNA"]): 3,
frozenset([]): 1,
frozenset(["gene", "exon", "mRNA", "CDS"]): 2,
frozenset(["exon", "mRNA", "CDS", "tRNA", "intron", "gene"]): 1,
}
assert c.feature_classes == {
bed[0]: set(["."]),
bed[1]: set(["gene", "exon", "mRNA", "CDS"]),
bed[2]: set(["intron", "gene", "mRNA"]),
bed[3]: set(["intron", "gene", "mRNA"]),
bed[4]: set(["tRNA", "UTR", "exon", "mRNA", "CDS", "gene"]),
bed[5]: set(["gene", "exon", "mRNA", "CDS"]),
bed[6]: set(["intron", "gene", "mRNA"]),
bed[7]: set(["tRNA", "intron", "exon", "mRNA", "CDS", "gene"]),
}
print "use these indexes for debugging"
for i, f in enumerate(bed):
print i, f
for k, v in c.class_features.items():
print k
for i in v:
print "\t" + str(i)
assert c.class_features == {
frozenset([]): [bed[0]],
frozenset(["intron", "gene", "mRNA"]): [bed[6], bed[2], bed[3]],
frozenset(["gene", "exon", "mRNA", "CDS"]): [bed[5], bed[1]],
frozenset(["UTR", "exon", "mRNA", "CDS", "tRNA", "gene"]): [bed[4]],
frozenset(["exon", "mRNA", "CDS", "tRNA", "intron", "gene"]): [bed[7]],
}
开发者ID:lbeltrame,项目名称:pybedtools,代码行数:42,代码来源:test_contrib.py
示例18: test_links
def test_links():
# have to be careful about the path, since it is embedded in the HTML
# output.
a = pybedtools.BedTool(
os.path.join(
os.path.relpath(pybedtools.data_dir()),
'a.bed'))
a = a.links()
exp = open(pybedtools.example_filename('a.links.html')).read()
obs = open(a.links_html).read()
assert exp == obs
开发者ID:libor-m,项目名称:pybedtools,代码行数:11,代码来源:test1.py
示例19: test_gzipped_output
def test_gzipped_output():
_filename = pybedtools.example_filename('a.bed')
compressed_file = pybedtools.BedTool(_filename).saveas(compressed=True)
# Open gzipped file in text mode
with gzip.open(compressed_file.fn, 'rt') as gf:
uncompressed_content = gf.read()
with open(_filename) as f:
original_content = f.read()
assert_equal(original_content, uncompressed_content)
开发者ID:PanosFirmpas,项目名称:pybedtools,代码行数:12,代码来源:test_gzip_support.py
示例20: test_getting_example_beds
def test_getting_example_beds():
assert 'a.bed' in pybedtools.list_example_files()
a_fn = pybedtools.example_filename('a.bed')
assert a_fn == os.path.join(testdir, 'data', 'a.bed')
a = pybedtools.example_bedtool('a.bed')
assert a.fn == os.path.join(testdir, 'data', 'a.bed')
# complain appropriately if nonexistent paths are asked for
assert_raises(ValueError, pybedtools.example_filename, 'nonexistent')
assert_raises(ValueError, pybedtools.example_bedtool, 'nonexistent')
assert_raises(ValueError, pybedtools.set_tempdir, 'nonexistent')
开发者ID:Fabrices,项目名称:pybedtools,代码行数:13,代码来源:test_helpers.py
注:本文中的pybedtools.example_filename函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论