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

  • 910ecf4
  • /
  • utils
  • /
  • nucmer_parser.py
Raw File Download

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
content badge Iframe embedding
swh:1:cnt:508276ad66212ebdc1dce8b854825ea30d90c376
directory badge Iframe embedding
swh:1:dir:fdfbc8ce7f5ad712860694246e7cf5b3c069e96e

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
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
nucmer_parser.py
from collections import namedtuple, defaultdict

from .common import AlignmentRow, AlignmentColumn

#(c) 2013-2014 by Authors
#This file is a part of Ragout program.
#Released under the BSD license (see LICENSE file)

"""
Some helper functions to parse/process nucmer output
"""

def parse_nucmer_coords(filename):
    chr_alias = {}
    chr_num = 1

    alignment = []
    for line in open(filename, "r"):
        line = line.strip()
        if not len(line) or not line[0].isdigit():
            continue

        vals = line.split(" | ")
        s_ref, e_ref = list(map(int, vals[0].split()))
        s_qry, e_qry = list(map(int, vals[1].split()))
        len_ref, len_qry = list(map(int, vals[2].split()))
        ref_id, qry_id = vals[4].split("\t")

        if e_ref > s_ref:
            ref_strand = 1
        else:
            ref_strand = -1
            s_ref, e_ref = e_ref, s_ref

        if e_qry > s_qry:
            qry_strand = 1
        else:
            qry_strand = -1
            s_qry, e_qry = e_qry, s_qry

        if ref_id not in chr_alias:
            chr_alias[ref_id] = "chr{0}".format(chr_num)
            chr_num += 1

        ref_row = AlignmentRow(s_ref, e_ref, ref_strand, None,
                                                chr_alias[ref_id])
        qry_row = AlignmentRow(s_qry, e_qry, qry_strand, None, qry_id)
        alignment.append(AlignmentColumn(ref_row, qry_row))

    return alignment

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