Giter Site home page Giter Site logo

Comments (5)

daler avatar daler commented on July 28, 2024 1

In general, I think cases like this are best handled by using a custom function supplied to .each(). But there's an existing function gff2bed() you could use for .each():

import pybedtools
from pybedtools.featurefuncs import gff2bed
b = pybedtools.example_bedtool('d.gff')
print b
chr1    fake    gene    50  300 .   +   .   ID=gene1
chr1    fake    mRNA    50  300 .   +   .   ID=mRNA1;Parent=gene1;
chr1    fake    CDS 75  150 .   +   .   ID=CDS1;Parent=mRNA1;
chr1    fake    CDS 200 275 .   +   .   ID=CDS2;Parent=mRNA1;
chr1    fake    rRNA    1200    1275    .   +   .   ID=rRNA1;
c = b.each(gff2bed).saveas('out.bed', trackline='track name=test')
print c
track name=test
chr1    49  300 gene1   .   +
chr1    49  300 mRNA1   .   +
chr1    74  150 CDS1    .   +
chr1    199 275 CDS2    .   +
chr1    1199    1275    rRNA1   .   +

Does this do what you want?

from pybedtools.

yarden avatar yarden commented on July 28, 2024

Yes, thanks, this is very elegant -- did not know about gff2bed.

from pybedtools.

daler avatar daler commented on July 28, 2024

Good to hear. If you have any other commonly-used transformations, I can put them in featurefuncs as well.

(closing this for now, but please reopen if needed)

from pybedtools.

yarden avatar yarden commented on July 28, 2024

Quick followup: Is there an equivalent bed2gff somewhere that I missed? thanks

from pybedtools.

daler avatar daler commented on July 28, 2024

Just added featurefuncs.bed2gff (added in 7cff02f) -- see if this does the trick.

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.