Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/vejnar/LabxPipe
02 May 2023, 09:53:20 UTC
  • Code
  • Branches (1)
  • Releases (8)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • v0.6.0
    • v0.5.0
    • v0.4.0
    • v0.3.0
    • v0.2.0
    • v0.1.2
    • v0.1.1
    • v0.1.0
  • f4c2bd6
  • /
  • src
  • /
  • labxpipe_scripts
  • /
  • lxpipe_profile.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:7aef753b79281cd0d0dfd781b003e899638d9850
origin badgedirectory badge
swh:1:dir:6bf3e7e1f8ddcbe72188ffdef81445fa3dc9c885
origin badgerevision badge
swh:1:rev:adf29e860d11a9d1d3ecb06afff81bbf46207d62
origin badgesnapshot badge
swh:1:snp:cc771c9e970c5a9ae56f266e0d2aa3ecec08a923

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: adf29e860d11a9d1d3ecb06afff81bbf46207d62 authored by vejnar on 19 April 2023, 15:50:13 UTC
Add --suffix to extract command
Tip revision: adf29e8
lxpipe_profile.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#
# Copyright © 2013 Charles E. Vejnar
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://www.mozilla.org/MPL/2.0/.
#

"""Profile & count using GeneAbacus"""

import argparse
import json
import os
import re
import subprocess
import sys

import pyfnutils as pfu
import pyfnutils.parallel

from labxpipe.interfaces import if_exe_geneabacus
from labxpipe import parallel_helpers

def main(argv=None):
    if argv is None:
        argv = sys.argv
    # Started from wrapper?
    prog = os.path.basename(argv[0])
    if len(argv) > 1 and argv[1] == 'profile':
        job_cmd = argv[:2]
        argv_parser = argv[2:]
        prog += ' profile'
    else:
        job_cmd = argv[:1]
        argv_parser = argv[1:]
    # GeneAbacus help
    p = subprocess.run(['geneabacus', '-h'], check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
    geneabacus_help_re = []
    for line in p.stdout.split('\n'):
        res = re.match('^\s+(-\w.*)', line)
        if res is None:
            geneabacus_help_re.append(line)
        else:
            geneabacus_help_re.append('  -' + res.group(1))
    geneabacus_help = '\n'.join(geneabacus_help_re)
    # Arguments parser
    parser = argparse.ArgumentParser(prog=prog, formatter_class=argparse.RawDescriptionHelpFormatter, description='Profile and count using GeneAbacus.', epilog=geneabacus_help)
    parser.add_argument('-e', '--path_schema', dest='path_schema', action='store', required=True, help='Path to schema input file')
    parser.add_argument('-n', '--bam_folder', dest='bam_folder', action='store', default='aligning', help='Folder of BAM(s) input file (comma separated)')
    parser.add_argument('-b', '--bam_fname', dest='bam_fname', action='store', default='accepted_hits.bam', help='Filename of BAM input file')
    parser.add_argument('--input_sam', dest='input_sam', action='store_true', help='Input is SAM')
    parser.add_argument('-r', '--path_root_bams', dest='path_root_bams', action='store', default='.', help='Root path to BAM(s) input file (comma separated)')
    parser.add_argument('-o', '--path_root_output', dest='path_root_output', action='store', default='.', help='Root path to output')
    parser.add_argument('-s', '--label_suffix', dest='label_suffix', action='store', default='', help='Label suffix (i.e. _plus or _unique)')
    parser.add_argument('-p', '--processor', dest='num_processor', action='store', type=int, default=1, help='Number of processor')
    parser.add_argument('--verbose', dest='verbose', action='store_true', help='Verbose')
    args, other_args = parser.parse_known_args(argv_parser)

    # Parse GeneAbacus arguments
    count_options = {}
    if args.verbose:
        count_options['verbose'] = True
    i = 0
    while i < len(other_args):
        arg = other_args[i].lstrip('-')
        if other_args[i].startswith('-') and (i + 1) != len(other_args) and (other_args[i+1] == '-' or not other_args[i+1].startswith('-')):
            count_options[arg] = other_args[i+1]
            i += 2
        else:
            count_options[arg] = True
            i += 1

    # Read schema
    schema = json.load(open(args.path_schema, 'rt'))

    # Prepare job(s)
    jobs = parallel_helpers.get_count_jobs(merging_schema   = schema['merging'],
                                           path_root_bams   = args.path_root_bams.split(','),
                                           path_root_output = args.path_root_output,
                                           bam_folder       = args.bam_folder.split(','),
                                           bam_fname        = args.bam_fname,
                                           label_suffix     = args.label_suffix,
                                           input_sam        = args.input_sam,
                                           count_options    = count_options,
                                           check            = True)

    # Run job(s)
    r = pfu.parallel.run(if_exe_geneabacus.geneabacus, jobs, num_processor=args.num_processor)

if __name__ == '__main__':
    sys.exit(main())

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API