File: gfapy-diff

package info (click to toggle)
gfapy 1.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,036 kB
  • sloc: python: 11,777; sh: 167; makefile: 68
file content (47 lines) | stat: -rwxr-xr-x 1,098 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
"""
Compare two GFA files

Note: the current version is not yet functional and only checking segments.
Work in progress.
"""

import sys
import os
import gfapy
import argparse

op = argparse.ArgumentParser(description=__doc__)
op.add_argument('--version', action='version', version='%(prog)s 0.1')
op.add_argument("filename1")
op.add_argument("filename2")
opts = op.parse_args()

gfa1 = gfapy.Gfa.from_file(opts.filename1)
gfa2 = gfapy.Gfa.from_file(opts.filename2)

different = False

if gfa1.version != gfa2.version:
  print("# different version")
  exit(1)
else:
  for s in gfa1.segments:
    s2 = gfa2.segment(s)
    if s2 is None:
      different = True
      print("# segment {} in {} but not in {}".format(s.name, opts.filename1, opts.filename2))
    if s.diff(s2):
      different = True
      for diff in s.diff(s2):
        print(diff)
  for s in gfa2.segments:
    s1 = gfa1.segment(s)
    if s1 is None:
      different = True
      print("# segment {} in {} but not in {}".format(s.name, opts.filename2, opts.filename1))

if different:
  exit(1)
else:
  exit(0)