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

Revision 119e6dc90ce3bd0295ee9befac2dd168e69116df authored by Mikhail Kolmogorov on 18 July 2018, 20:14:16 UTC, committed by Mikhail Kolmogorov on 18 July 2018, 20:14:16 UTC
some auxialary scipts changes
1 parent 2c85472
  • Files
  • Changes
  • 0b4ecb0
  • /
  • scripts
  • /
  • chromosome-report.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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:119e6dc90ce3bd0295ee9befac2dd168e69116df
directory badge
swh:1:dir:cebde40034378667d1ccf9347e427744435f8e8a
content badge
swh:1:cnt:06631ea0e1b35ff1760ac4a9174205b8737f34a5

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.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
chromosome-report.py
#!/usr/bin/env python2.7

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

"""
A diagnostic script for chromosome fusions
"""

from __future__ import print_function
import sys
from collections import defaultdict

REF_NAME = "C57B6J"

def do_job(links_file, target_perms, all_blocks):
    block_chrs = {}
    with open(all_blocks, "r") as f:
        for line in f:
            line = line.strip()
            if line.startswith(">"):
                tokens = line[1:].split(".", 1)
                genome_name, chr_name = tokens
            elif genome_name != REF_NAME:
                continue
            else:
                blocks_ids = map(int, line.split(" ")[:-1])
                for b in blocks_ids:
                    block_chrs[abs(b)] = chr_name

    target_chrs = defaultdict(list)
    with open(target_perms, "r") as f:
        for line in f:
            line = line.strip()
            if line.startswith(">"):
                seq_name = line[1:]
            else:
                blocks_ids = map(int, line.split(" ")[:-1])
                for b in blocks_ids:
                    block_chr = block_chrs.get(abs(b), None)
                    if (not block_chr or not target_chrs[seq_name] or
                        target_chrs[seq_name][-1] != block_chr):
                        target_chrs[seq_name].append(str(b) + ":" + block_chr)

    with open(links_file, "r") as f:
        for line in f:
            line = line.strip()
            if not line or line.startswith("--") or line.startswith("sequence"):
                continue
            if line[0] not in "+-":
                print("\n" + line + "\n")
                continue

            sign, contig_name = line[0], line.split()[0][1:]
            blocks = (target_chrs[contig_name] if sign == "+"
                      else target_chrs[contig_name][::-1])
            print(sign, contig_name, blocks)


def main():
    if len(sys.argv) != 4:
        print("Usage: chromosome-report.py links target_perms all_perms")
        return 1
    do_job(sys.argv[1], sys.argv[2], sys.argv[3])
    return 0


if __name__ == "__main__":
    main()

The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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