Giter Club home page Giter Club logo

Comments (4)

daler avatar daler commented on July 30, 2024

This one doesn't work because there's no support for creation from a tuple (e.g., try printing loc -- TypeError is raised). This should be supported, so I'll add it.

# ...
# no content in .seqfn
loc = BedTool([(chrom, start, end)])
print open(loc.sequence(fi=fa).seqfn).read()

This one doesn't work because there's no newline at the end of the file. The latest versions use the full line, plus the "\n", as the definition of a feature; using the from_string kwarg adds the newlines. I'll add some more checks on this so that it's supported as well.

# ...
# no content in .seqfn
out = open('t.fa', 'w')
out.write("%s\t%i\t%i" % (chrom, start, end))
out.close()
loc = BedTool(out.name)
print open(loc.sequence(fi=fa).seqfn).read()

Adding a newline to the created file makes it work:

from pybedtools import BedTool
import pybedtools
chrom, start, end = "chr1", 1, 10
fa = pybedtools.example_filename('test.fa')
out = open('t.fa', 'w')

# add newline too
out.write("%s\t%i\t%i\n" % (chrom, start, end))

out.close()
loc = BedTool(out.name)
print open(loc.sequence(fi=fa).seqfn).read()

from pybedtools.

brentp avatar brentp commented on July 30, 2024

ah, thanks for looking into it. Yes, the docs do say you can create from a tuple.
I missed that about having a newline. doh!

from pybedtools.

daler avatar daler commented on July 30, 2024

Turns out it's BEDTools that doesn't support a one-feature BED file with no newline -- with your original example,

$ bedtools getfasta -bed t.fa -fi pybedtools/test/data/test.fa -fo res.fa
$ wc -l res.fa
0 res.fa

Maybe because it doesn't know if it's in the middle of a stream? Should hit EOF though . . . anyway, it's a corner case, and not sure if it should be supported or not by BEDTools.

Also, I just opened a separate issue for the creation from tuple . . . so closing this one for now.

from pybedtools.

arq5x avatar arq5x commented on July 30, 2024

Hmm, BEDTools should handle this. I suspect it's an untested corner case that arose from my latest restructuring of the API. I'll ook into this soon.

from pybedtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.