Comments (9)
self._bed.fields[key] = string(value)
then the key still has to be an integer. for the key as a string maybe (untested)
if isinstance(key, basestring):
setattr(self, key)
from pybedtools.
OK, trying to setitem sort of works:
def __setitem__(self, object key, object value):
if isinstance(key, (int,long)):
nfields = self._bed.fields.size()
if key >= nfields:
raise IndexError('field index out of range')
elif key < 0: key = nfields + key
self._bed.fields[key] = string(value)
elif isinstance(key, (basestring)):
setattr(self, key, value)
it looks like the chrom is getting changed (verified by printing the fields) but this is not recognized when i access Interval.chrom . . . see the test at:
https://github.com/daler/pybedtools/blob/exp/pybedtools/test/test_cbedtools.py#L117
the failed test shows this:
FAIL: testSetItem (pybedtools.test.test_cbedtools.IntervalTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ryan/proj/pybedtools/pybedtools/test/test_cbedtools.py", line 123, in testSetItem
self.assertEqual(iv['chrom'], 'fake')
AssertionError: 'chr21' != 'fake'
-------------------- >> begin captured stdout << ---------------------
['fake', '9719768', '9721892', 'ALR/Alpha', '1004', '+']
--------------------- >> end captured stdout << ----------------------
my guess is that a similar issue causes testAppend to fail as well:
https://github.com/daler/pybedtools/blob/exp/pybedtools/test/test_cbedtools.py#L126
from pybedtools.
ah. it's because sometimes it's setting/getting the .chrom property in c++ (with the string) and others it's setting/getting the field (with the integer key).
i'll think about how to fix.
from pybedtools.
i ran into all sorts of issues trying to get this to work 1) with GFF files and 2) BED files that get something appended to them (and therefore getting nonempty otherFields vector).
i made some changes to getitem, which pays attention to the current length of fields and otherFields.
However, it looks like a GFF Interval, when created, gets 3 things put in its otherFields. I tried to account for this in the new getitem, but this seems like the wrong way to do it.
Can you explain how fields and otherFields should work for GFF files and for BED files of various lengths (say, BED3 vs BED9)?
from pybedtools.
OK, found the answer to my question in bedtool.h -- GFF parser puts "source", "fname", and "group" in the otherFields vector, while the rest of the GFF line goes into the standard BED6 fields. BED7+ has 7th and beyond placed into otherFields as expected.
from pybedtools.
i am also working on this a bit. trying to make it much simpler in the c and cython parts.
from pybedtools.
we'll have to check that all the set and normal property setters also update fields.
(note to self) make sure the field is in LOOKUPS and follow the set for chrom/ or start/end.
from pybedtools.
the .name setting is not working for GFF/GTF. needs something like:
self._bed.fields[8] = string(";".join("%s=%s" % (k, v) for k,v in attrs.iteritems()))
but also account for GTF
from pybedtools.
this is fixed as of your: d391fae yes?
from pybedtools.
Related Issues (20)
- 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
- how to mask gap regions for randomization? HOT 1
- Issue while doing pip install pybedtools HOT 3
- Inconsistent behaviour when using files from `pathlib.PosixPath` with BedTool functions...
- pybedtools.bedtool.Bedtool.sort()
- total_coverage giving a incorrect value
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.