How to use the pypeline.node.CommandNode function in Pypeline

To help you get started, we’ve selected a few Pypeline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MikkelSchubert / paleomix / pypeline / nodes / depthhist.py View on Github external
kwargs["IN_STDIN"] = cat_obj
            input_argument = "-"  # Read from STDIN
        else:
            cat_cmds = []
            kwargs["IN_FILE"] = input_files[0]
            input_argument = "%(IN_FILE)s"

        call = ['bam_depths', input_argument, '%(OUT_FILE)s',
                '--target-name', target_name]
        builder = AtomicCmdBuilder(call, **kwargs)
        if regions_file:
            builder.set_option('--regions-file', '%(IN_REGIONS)s')
            builder.set_kwargs(IN_REGIONS=regions_file)

        command = ParallelCmds(cat_cmds + [builder.finalize()])
        CommandNode.__init__(self,
                             command=command,
                             description=" '%s'>"
                                         % (describe_files(input_files),
                                            output_file),
                             dependencies=dependencies)
github MikkelSchubert / paleomix / pypeline / nodes / muscle.py View on Github external
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
# SOFTWARE.
#
import os

from pypeline.node import CommandNode, MetaNode
from pypeline.atomiccmd import AtomicCmd


class MuscleNode(CommandNode):
    def __init__(self, infile, prefix, dependencies = ()):
        call = ["muscle",
                "-quiet",
                "-maxiters", 32,
                "-in", "%(IN_FASTA)s",
                "-fastaout", "%(OUT_AFA)s",
                "-phyiout",  "%(OUT_PHYS)s"]

        command = AtomicCmd(call,
                            IN_FASTA = infile,
                            OUT_AFA  = prefix + ".afa",
                            OUT_PHYS = prefix + ".phy")

        description = " '%s'>" \
                % (infile, prefix + ".*")
github MikkelSchubert / paleomix / pypeline / nodes / depthhist.py View on Github external
from pypeline.node import \
    CommandNode
from pypeline.atomiccmd.sets import \
    ParallelCmds
from pypeline.atomiccmd.builder import \
    AtomicCmdBuilder
from pypeline.nodes.picard import \
    concatenate_input_bams

from pypeline.common.fileutils import \
    describe_files
from pypeline.common.utilities import \
    safe_coerce_to_tuple


class DepthHistogramNode(CommandNode):
    def __init__(self, config, target_name, input_files, output_file,
                 regions_file=None, dependencies=()):
        kwargs = {"OUT_FILE": output_file}
        input_files = safe_coerce_to_tuple(input_files)

        if len(input_files) > 1:
            if regions_file:
                raise ValueError("DepthHistogram for regions require single, "
                                 "indexed input BAM file.")
            cat_cmds, cat_obj = concatenate_input_bams(config, input_files)
            kwargs["IN_STDIN"] = cat_obj
            input_argument = "-"  # Read from STDIN
        else:
            cat_cmds = []
            kwargs["IN_FILE"] = input_files[0]
            input_argument = "%(IN_FILE)s"
github MikkelSchubert / paleomix / pypeline / nodes / muscle.py View on Github external
call = ["muscle",
                "-quiet",
                "-maxiters", 32,
                "-in", "%(IN_FASTA)s",
                "-fastaout", "%(OUT_AFA)s",
                "-phyiout",  "%(OUT_PHYS)s"]

        command = AtomicCmd(call,
                            IN_FASTA = infile,
                            OUT_AFA  = prefix + ".afa",
                            OUT_PHYS = prefix + ".phy")

        description = " '%s'>" \
                % (infile, prefix + ".*")

        CommandNode.__init__(self,
                             command      = command,
                             description  = description,
                             dependencies = dependencies)