Comments (9)
working on this now.
from pybedtools.
so we can do this, but you can't add slots declarations to a dynamically generated class, so we'd have to use another arbitrary name.
the other problem is that if you have a bed file, it might only contain 4 columns, but the slots dictionary has 12.
... having trouble thinking how to do it cleanly.
from pybedtools.
'doh. i'll have to play with slots some more, i was hoping that sort of thing would be solved with a zip()
stopping upon hitting the end of the shortest list (e.g., the 4 items).
does this help at all? (from http://docs.python.org/reference/datamodel.html#slots):
Without a dict variable, instances cannot be assigned new variables not listed in the slots definition. Attempts to assign to an unlisted variable name raises AttributeError. If dynamic assignment of new variables is desired, then add 'dict' to the sequence of strings in the slots declaration.
from pybedtools.
yeah, the problem is that you can't define the slots dynamically. so neither:
DynamicBed = type('DynamicBed', (BedFeature, ), dict(__slots__=['blah']))
nor:
def some_func(some_vars)
class DynamicBed(BedFeature):
__slots__ = some_vars
will work. because the slots are defined at, um, compile time. which makes sense, in retrospect... i left what i had at my work machine, i can check it in on monday.
from pybedtools.
Ah now I see. It make sense now after seeing it written out like that.
Do you think it's worth having a DerivedFeature base class that acts similarly to Feature but doesn't have the speed of slots? Though I guess that would mean copying all the GFFFeature, BedFeature, etc code to the new DerivedGFFFeature, DerivedBedFeature etc . . . which would get ugly fast.
from pybedtools.
yes, i think that might work. i will (time allowing) prototype on monday. it wont take too long, just have to change init et al to use _dynamic_slots instead of slots
and it wont require copying all of them, only the Feature class will have an orthologous DynamicFeature... i think.
from pybedtools.
cool. take your time, no rush.
from pybedtools.
so i put what i had for the start of this here: https://gist.github.com/890525
it's not working because of the slots stuff we mentioned above. and it's pretty ugly.
so then in closest(), it just has:
if 'keep_new' in kwargs:
return self._keep_cols(tmp, other, kwargs['keep_new'])
but i think the way i have it set up is too complex--and fragile because it depends on the column numbers. any ideas?
from pybedtools.
tricky . . . i'll have to think about this and fiddle around some more.
i agree, the column numbers seems easy to break, but then again that's what the "canonical" feature classes are using to parse a line into slots in the first place, so that part is prob fine.
from pybedtools.
Related Issues (20)
- 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
- 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()
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.