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/ctlab/quant3p
25 December 2019, 16:37:49 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/bedtools
    • refs/heads/master
    No releases to show
  • 34f2683
  • /
  • bin
  • /
  • macs2-stranded
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 Iframe embedding
swh:1:cnt:5f7be0e0288e98ebaf62decf3c118900be29186e
origin badgedirectory badge Iframe embedding
swh:1:dir:5b653c90d686c5fd21bed29c1f8bafb2420ece4f
origin badgerevision badge
swh:1:rev:be9977925e9e842cc755f14ced72bbee5c5d6d77
origin badgesnapshot badge
swh:1:snp:c3876493dcdf8da1d2957e6b67a7a1bacbc80fe5

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: be9977925e9e842cc755f14ced72bbee5c5d6d77 authored by Alexey Sergushichev on 02 December 2019, 17:22:45 UTC
fixes for htseq & macs2 upgrades
Tip revision: be99779
macs2-stranded
#!/usr/bin/env bash

#### Set up

SCRIPTNAME=`basename $0`
function error() 
{
    local PARENT_LINENO="$1"
    local MESSAGE="$2"
    local CODE="${3:-1}"
    if [[ -n "$MESSAGE" ]] ; then
        echo "$SCRIPTNAME: Error on or near line ${PARENT_LINENO}: ${MESSAGE}; exiting with status ${CODE}"
    else
        echo "$SCRIPTNAME: Error on or near line ${PARENT_LINENO}; exiting with status ${CODE}"
    fi
    exit "${CODE}"
}

trap 'error ${LINENO}' ERR
# setting exit on error and inheriting of ERR trap
set -eE

die()
{
    if [ -n "$@" ]; then
        echo "$@" >&2
    else
        echo "FAILED" >&2
    fi
    exit 1
}


#### Arguments

GSIZE="3e9"
QVALUE="0.01"

# help message
help()
{
    echo "usage: $SCRIPTNAME <options> <bam-file>+"
    echo ""
    echo "mandatory arguments:"
    echo "-n NAME name of the experiment; mandatory"
    echo ""
    echo "optional arguments:"
    echo "--keep-temp keep temporary files"
    echo "-g GSIZE approximate size of the genome (for MACS); default = $GSIZE"
    echo "-q QVALUE q-value cutoff (for MACS); default = $QVALUE"
    echo "-h|--help shows this message and exit"
}


if [ $# -eq 0 ]; then
    help
    exit
fi

while true; do
    case "$1" in
        -n) NAME="$2"; shift 2;;
        -g) GSIZE="$2"; shift 2;;
        -q) QVALUE="$2"; shift 2;;
        --keep-temp) KEEP_TEMP="--keep-temp"; shift 1;;
        -h|--help) help; exit 0;;
        --) shift 1; break;;
        -*) die "unrecognized option: $1";;
        *) break;;
    esac
done

if [ -z "$NAME" ]; then
    die "NAME is not specified (try -h for details)"
fi

BAMS=("$@")


#### Run

echo "Calling peaks"

macs_pos_dir="${NAME}.pos.macs"
macs_neg_dir="${NAME}.neg.macs"


if [[ ${#BAMS[@]} -gt 1 ]]; then
    CAT_CMD="samtools cat -o -"
else
    CAT_CMD="cat"
fi

$CAT_CMD "${BAMS[@]}" | samtools view | head -100 > peek.sam
TAG_SIZE=$(( $(cut -f 10 peek.sam | wc -c) / $(cat peek.sam | wc -l) ))

macs2 callpeak -t <($CAT_CMD "${BAMS[@]}" | samtools view -F 16 -b - |  bedtools bamtobed -i - -split) \
    --outdir "${macs_pos_dir}" -s $TAG_SIZE --nomodel -f BED -g "$GSIZE" \
    -n "${NAME}.pos" -q "$QVALUE" & pos_pid="$!"
macs2 callpeak -t <($CAT_CMD "${BAMS[@]}" | samtools view -f 16 -b - |  bedtools bamtobed -i - -split) \
    --outdir "${macs_neg_dir}" -s $TAG_SIZE --nomodel -f BED -g "$GSIZE" \
    -n "${NAME}.neg" -q "$QVALUE" & neg_pid="$!"

wait $pos_pid 
wait $neg_pid

echo "Combining peaks"
 
cat <(sed "s/\t\.\t/\t+\t/" "${macs_pos_dir}/${NAME}.pos_peaks.narrowPeak") \
    <(sed "s/\t\.\t/\t-\t/" "${macs_neg_dir}/${NAME}.neg_peaks.narrowPeak") \
    > ${NAME}_peaks.narrowPeak

if [ -z "${KEEP_TEMP}" ]; then
    rm -rv "${macs_pos_dir}" "${macs_neg_dir}"
fi

echo "Done"

back to top

Software Heritage — Copyright (C) 2015–2025, 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