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
  • 1fb4720
  • /
  • src
  • /
  • labxpipe
  • /
  • parallel_helpers.py
Raw File Download Save again
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
  • release
origin badgecontent badge
swh:1:cnt:7b4b2dbd5011f5641c748174a876869478fdda23
origin badgedirectory badge
swh:1:dir:cf71e26a52e77a15dd3a1ee0498492db1fc22786
origin badgerevision badge
swh:1:rev:5519892059f56f02c4e2da8490c50f98b08e592b
origin badgesnapshot badge
swh:1:snp:cc771c9e970c5a9ae56f266e0d2aa3ecec08a923
origin badgerelease badge
swh:1:rel:1c2ae229d509a6e9ea2d9ff7ee0a66f2a6f06379

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
  • release
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 5519892059f56f02c4e2da8490c50f98b08e592b authored by vejnar on 05 April 2023, 16:19:02 UTC
Add samtools_sort step
Tip revision: 5519892
parallel_helpers.py
# -*- 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/.
#

"""Helper functions for parallel processing of runs."""

import os

def format2ext(pff):
    pff_split = pff.split('+')
    if len(pff_split) == 1:
        pf, pz = pff_split[0], None
    else:
        pf, pz = pff_split[0], pff_split[1]
    if pf == 'binary':
        ext = '.bin'
    elif pf =='bedgraph':
        ext = '.bedgraph'
    elif pf == 'csv':
        ext = '.csv'
    if pz == 'lz4':
        ext += '.lz4'
    return ext

def get_count_jobs(merging_schema,
                   path_root_bams = ['.'],
                   path_root_output = '.',
                   bam_folder = ['aligning'],
                   bam_fname = None,
                   label_suffix = '',
                   input_sam = False,
                   count_options = {},
                   check = False):
    jobs = []
    for run in merging_schema:
        # Init. job
        job = count_options.copy()
        if 'options' in run:
            job.update(run['options'])

        # Input: Path to BAM(s)
        if input_sam:
            key_input = 'path_sam'
        else:
            key_input = 'path_bam'
        job[key_input] = []
        for ref in run['refs']:
            for path_root_bam in path_root_bams:
                if bam_fname is not None:
                    p = os.path.join(path_root_bam, ref, *bam_folder, bam_fname)
                else:
                    if input_sam:
                        p = os.path.join(path_root_bam, ref+'.sam')
                    else:
                        p = os.path.join(path_root_bam, ref+'.bam')
                if os.path.exists(p):
                    job[key_input].append(p)
        if check:
            assert len(job[key_input]) > 0, f"No SAM/BAM found for {run['refs']}"

        # Output: Counts
        if 'count_path' not in job:
            job['count_path'] = os.path.join(path_root_output, run['name'] + label_suffix + '_counts.csv')
        # Output: Profiles
        if 'profile_formats' in count_options and 'profile_paths' not in count_options:
            if isinstance(job['profile_formats'], list):
                profile_formats = job['profile_formats']
            else:
                profile_formats = job['profile_formats'].split(',')
            job['profile_paths'] = [os.path.join(path_root_output, run['name'] + label_suffix + '_profiles' + format2ext(pff)) for pff in profile_formats]

        # Add job with BAM total file size
        jobs.append([job, sum([os.path.getsize(f) for f in job[key_input]])])

    # Sort job(s) by BAM size
    jobs.sort(key=lambda j: j[1], reverse=True)

    return [j[0] for j in jobs]

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