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/GeneAbacus
20 February 2026, 23:11:59 UTC
  • Code
  • Branches (1)
  • Releases (6)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • v0.2.2
    • v0.2.1
    • v0.2.0
    • v0.1.2
    • v0.1.1
    • v0.1
  • b878b8a
  • /
  • lib
  • /
  • esam
  • /
  • esam.go
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:d61638213da61169afcda17c91ad548ae43f5cc7
origin badgedirectory badge
swh:1:dir:39d35e446a20a2386f6e24f0a39c279d9149e531
origin badgerevision badge
swh:1:rev:abea966ebc8d4fc7fee5cd87db27828e38bb9dec
origin badgesnapshot badge
swh:1:snp:c9ab8ea277d970770721ef06ce2eff7a73c0e990
origin badgerelease badge
swh:1:rel:9cddf9b46c4d3b1c2c8fec7685f447127cadca4b

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: abea966ebc8d4fc7fee5cd87db27828e38bb9dec authored by vejnar on 12 August 2022, 03:00:06 UTC
Fix source in CI
Tip revision: abea966
esam.go
//
// Copyright (C) 2015-2022 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/.
//

package esam

import (
	"github.com/biogo/hts/sam"
)

// PathSAM stores Path to SAM (Binary=false) or BAM (Binary=true) file.
type PathSAM struct {
	Path   string
	Binary bool
}

// Overlap returns the length of the overlap between the alignment of the SAM record and the interval specified with start and end.
func Overlap(r *sam.Record, start, end int) int {
	var overlap int
	pos := r.Pos
	for _, co := range r.Cigar {
		t := co.Type()
		con := t.Consumes()
		lr := co.Len() * con.Reference
		if con.Query == con.Reference {
			o := min(pos+lr, end) - max(pos, start)
			if o > 0 {
				overlap += o
			}
		}
		pos += lr
	}
	return overlap
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// ShiftPos shifts the coordinate within the alignment. If strand is -1, it starts from the alignment end.
func ShiftPos(pos int, shift int, r *sam.Record, strand int8) (int, bool) {
	shifted := 0
	var con sam.Consume
	var lr int
	if strand == 1 {
		for i := 0; i < len(r.Cigar); i++ {
			co := r.Cigar[i]
			con = co.Type().Consumes()
			lr = co.Len() * con.Query
			if shifted+lr < shift {
				pos += co.Len() * con.Reference
				shifted += lr
			} else {
				if con.Reference != 0 {
					return pos + ((shift - shifted) * con.Reference), true
				} else {
					return 0, false
				}
			}
		}
	} else {
		for i := len(r.Cigar) - 1; i >= 0; i-- {
			co := r.Cigar[i]
			con = co.Type().Consumes()
			lr = co.Len() * con.Query
			if shifted+lr < shift {
				pos -= co.Len() * con.Reference
				shifted += lr
			} else {
				if con.Reference != 0 {
					return pos - ((shift - shifted) * con.Reference), true
				} else {
					return 0, false
				}
			}
		}
	}
	return 0, false
}

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