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 57143f63aeab74207adb32a5a696d1dba0f3108c authored by Mikhail Kolmogorov on 16 May 2015, 00:13:58 UTC, committed by Mikhail Kolmogorov on 16 May 2015, 00:13:58 UTC
back to iterative BG + working rearrangements projection
1 parent 681fbff
  • Files
  • Changes
  • 82edcbe
  • /
  • scripts
  • /
  • run-tests.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:57143f63aeab74207adb32a5a696d1dba0f3108c
directory badge
swh:1:dir:ae29f864d3c1da457fbfb2d8892e8dfcb064a807
content badge
swh:1:cnt:af0ae95d3aa0e218dfcdc5c6146edd8b7bb09bcc

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 ...
run-tests.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 script for automatic testing
"""

from __future__ import print_function
import os
import subprocess
import shutil

TESTS = {"ecoli" : {"recipe" : "examples/E.Coli/ecoli.rcp",
                    "coords" : "examples/E.Coli/mg1655.coords",
                    "max_errors" : 0,
                    "max_errors_refine" : 0,
                    "min_contigs" : 79,
                    "min_contigs_refine" : 146,
                    "max_scaffolds" : 1,
                    "outdir" : "ecoli-test"},
         "helicobacter" : {"recipe" : "examples/H.Pylori/helicobacter.rcp",
                           "coords" : "examples/H.Pylori/SJM180.coords",
                           "max_errors" : 0,
                           "max_errors_refine" : 0,
                           "min_contigs" : 45,
                           "min_contigs_refine" : 126,
                           "max_scaffolds" : 1,
                           "outdir" : "helicobacter-test"},
         "cholerae" : {"recipe" : "examples/V.Cholerae/cholerae.rcp",
                       "coords" : "examples/V.Cholerae/h1.coords",
                       "max_errors" : 0,
                       "max_errors_refine" : 13,
                       "min_contigs" : 170,
                       "min_contigs_refine" : 720,
                       "max_scaffolds" : 3,
                       "outdir" : "cholerae-test"},
         "aureus" : {"recipe" : "examples/S.Aureus/aureus.rcp",
                     "coords" : "examples/S.Aureus/usa300.coords",
                     "max_errors" : 1,
                     "max_errors_refine" : 3,
                     "min_contigs" : 99,
                     "min_contigs_refine" : 182,
                     "max_scaffolds" : 1,
                     "outdir" : "aureus-test"}}

TEST_DIR = "test-dir"
RAGOUT_EXEC = "ragout.py"
VERIFY_EXEC = os.path.join("scripts", "verify-order.py")


def test_environment():
    if not os.path.isfile(RAGOUT_EXEC):
        raise RuntimeError("File \"{0}\" was not found".format(RAGOUT_EXEC))

    if not os.path.isfile(VERIFY_EXEC):
        raise RuntimeError("File \"{0}\" was not found".format(VERIFY_EXEC))


def run_test(parameters):
    outdir = os.path.join(TEST_DIR, parameters["outdir"])
    cmd = ["python2.7", "ragout.py", parameters["recipe"],
           "--outdir", outdir, "--debug"]
    print("Running:", " ".join(cmd), "\n")
    subprocess.check_call(cmd)

    links_simple = os.path.join(outdir, "scaffolds.links")
    links_simple_out = os.path.join(outdir, "scaffolds.links_verify")
    links_refined = os.path.join(outdir, "scaffolds_refined.links")
    links_refined_out = os.path.join(outdir, "scaffolds_refined.links_verify")

    #checking before refinement
    cmd = ["python2.7", VERIFY_EXEC, parameters["coords"], links_simple]
    print("Running:", " ".join(cmd), "\n")
    subprocess.check_call(cmd, stdout=open(links_simple_out, "w"))

    with open(links_simple_out, "r") as f:
        for line in f:
            if line.startswith("Total miss-ordered: "):
                value = int(line.strip()[20:])
                print("Errors:", value)
                if value > parameters["max_errors"]:
                    raise RuntimeError("Too many miss-ordered contigs")

            if line.startswith("Total contigs: "):
                value = int(line.strip()[15:])
                print("Contigs:", value)
                if value < parameters["min_contigs"]:
                    raise RuntimeError("Too few contigs")

            if line.startswith("Total scaffolds: "):
                value = int(line.strip()[17:])
                print("Scaffolds:", value)
                if value > parameters["max_scaffolds"]:
                    raise RuntimeError("Too many scaffolds")

    #checking after refinement
    cmd = ["python2.7", VERIFY_EXEC, parameters["coords"], links_refined]
    print("Running:", " ".join(cmd), "\n")
    subprocess.check_call(cmd, stdout=open(links_refined_out, "w"))

    with open(links_refined_out, "r") as f:
        for line in f:
            if line.startswith("Total miss-ordered: "):
                value = int(line.strip()[20:])
                print("Errors:", value)
                if value > parameters["max_errors_refine"]:
                    raise RuntimeError("Too many miss-ordered contigs")

            if line.startswith("Total contigs: "):
                value = int(line.strip()[15:])
                print("Contigs:", value)
                if value < parameters["min_contigs_refine"]:
                    raise RuntimeError("Too few contigs")

            if line.startswith("Total scaffolds: "):
                value = int(line.strip()[17:])
                print("Scaffolds:", value)
                if value > parameters["max_scaffolds"]:
                    raise RuntimeError("Too many scaffolds")


def main():
    test_environment()
    if os.path.isdir(TEST_DIR):
        shutil.rmtree(TEST_DIR)
    os.mkdir(TEST_DIR)

    for name, params in TESTS.items():
        print("\n********Running test:", name, "********\n")
        run_test(params)

    print("\n********All tests were succesfully completed********")
    #shutil.rmtree(TEST_DIR)


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