Comments (4)
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.
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.
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.
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)
- Support for Polars Dataframe needed HOT 2
- 'generator raised StopIteration' error when running 'randomstats' with multiple processes HOT 4
- IndexError with groupby HOT 1
- Could NOT find Arrow (missing: ARROW_INCLUDE_DIR ARROW_LIB_DIR HOT 2
- pybedtools.bedtool.BedTool.save_seqs leaves open .tmp files
- Support Python 3.10 and 3.11 HOT 1
- "python setup.py bdist_wheel did not run successfully" when pip installing with python v3.11 HOT 8
- to_dataframe() creates 0th row with generic names in nucleotide_content HOT 2
- build failure under python 3.11 HOT 6
- pybedtools intersect error HOT 2
- Cannot create a BedTool object from list of regions that uses np.int64 coordinates
- remove historical py27 support HOT 1
- bedtools intersect reported incorrect interval intersection HOT 3
- Cythonizing files requires `language_level=2` to be set in cythonize() HOT 4
- pybedtools multi_bam_coverage assistance HOT 2
- "fastaFromBed" error HOT 2
- intersect with multiple -b arguments not working with -sorted HOT 1
- Unable to install pybedtools==0.9.1 in Python3.10 HOT 4
- Len modifying the Bedtools after a filter HOT 2
- Has pybedtools considered packaging bedtools? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybedtools.