[med-svn] [Git][med-team/gfapy][upstream] New upstream version 1.2.2+dfsg

Sascha Steinbiss (@satta) gitlab at salsa.debian.org
Fri Jan 21 10:27:54 GMT 2022



Sascha Steinbiss pushed to branch upstream at Debian Med / gfapy


Commits:
d6805080 by Sascha Steinbiss at 2022-01-21T11:24:18+01:00
New upstream version 1.2.2+dfsg
- - - - -


22 changed files:

- CHANGES.txt
- README.rst
- doc/conf.py
- doc/tutorial/errors.rst
- doc/tutorial/positional_fields.rst
- doc/tutorial/references.rst
- gfapy/graph_operations/topology.py
- gfapy/line/edge/containment/containment.py
- gfapy/line/edge/containment/to_gfa2.py
- gfapy/line/edge/gfa1/other.py
- gfapy/line/edge/gfa1/references.py
- gfapy/line/edge/gfa1/to_gfa2.py
- gfapy/line/edge/gfa2/to_gfa1.py
- gfapy/line/edge/link/complement.py
- gfapy/line/edge/link/link.py
- gfapy/line/edge/link/to_gfa2.py
- setup.py
- tests/test_api_lines_finders.py
- tests/test_api_positionals.py
- tests/test_unit_line_connection.py
- tests/test_unit_line_dynamic_fields.py
- tests/test_unit_line_equivalence.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,8 @@
+== 1.2.2 ==
+
+- remove to/from aliases for GFA1 containment/link fields
+  since `to` potentially clashes with a tag name
+
 == 1.2.1 ==
 
 - fixed an issue with linear path merging (issue 21)


=====================================
README.rst
=====================================
@@ -1,7 +1,7 @@
 Gfapy
 ~~~~~
 
-|travis| |readthedocs| |latesttag| |license| |requiresio|
+|travis| |readthedocs| |latesttag| |license|
 
 |bioconda| |pypi| |debian| |ubuntu|
 


=====================================
doc/conf.py
=====================================
@@ -66,7 +66,7 @@ master_doc = 'index'
 
 # General information about the project.
 project = 'Gfapy'
-copyright = '2017--2021, Giorgio Gonnella and others (see CONTRIBUTORS)'
+copyright = '2017--2022, Giorgio Gonnella and others (see CONTRIBUTORS)'
 author = 'Giorgio Gonnella and others (see CONTRIBUTORS)'
 
 # The version info for the project you're documenting, acts as replacement for
@@ -76,7 +76,7 @@ author = 'Giorgio Gonnella and others (see CONTRIBUTORS)'
 # The short X.Y version.
 version = '1.2'
 # The full version, including alpha/beta/rc tags.
-release = '1.2.1'
+release = '1.2.2'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


=====================================
doc/tutorial/errors.rst
=====================================
@@ -29,7 +29,7 @@ all library errors.
 | `InconsistencyError`  | Pieces of information collide | length of sequence and LN tag   |
 |                       | with each other               | do not match                    |
 +-----------------------+-------------------------------+---------------------------------+
-| `RuntimeError`        | The user tried to do          | editing from/to field in        |
+| `RuntimeError`        | The user tried to do          | editing from_segment field in   |
 |                       | something which is not        | connected links                 |
 |                       | allowed                       |                                 |
 +-----------------------+-------------------------------+---------------------------------+


=====================================
doc/tutorial/positional_fields.rst
=====================================
@@ -23,7 +23,8 @@ Field names
 The field names are derived from the specification. Lower case versions
 of the field names are used and spaces are substituted with underscores.
 In some cases, the field names were changed, as they represent keywords
-in common programming languages (``from``, ``send``).
+in common programming languages or clash with potential tag names
+(``from``, ``to``, ``send``).
 
 The following tables shows the field names used in Gfapy, for each kind
 of line. Headers have no positional fields. Comments and custom records


=====================================
doc/tutorial/references.rst
=====================================
@@ -60,9 +60,9 @@ GFA1
 +---------------+-------------------+---------------------------+
 | Record type   | Fields            | Type of reference         |
 +===============+===================+===========================+
-| Link          | from, to          | Segment                   |
+| Link          | from_segment, to_segment | Segment            |
 +---------------+-------------------+---------------------------+
-| Containment   | from, to          | Segment                   |
+| Containment   | from_segment, to_segment | Segment            |
 +---------------+-------------------+---------------------------+
 | Path          | segment\_names,   | [OrientedLine(Segment)]   |
 +---------------+-------------------+---------------------------+
@@ -361,7 +361,8 @@ Renaming an element
 
 The name field of a line (e.g. segment ``name``/``sid``) is not a
 reference and thus can be edited also in connected lines. When the name
-of the line is changed, no manual editing of references (e.g. from/to
+of the line is changed, no manual editing of references (e.g.
+``from_segment``/``to_segment``
 fields in links) is necessary, as all lines which refer to the line will
 still refer to the same instance. The references to the instance in the
 Gfa lines collections will be automatically updated. Also, the new name


=====================================
gfapy/graph_operations/topology.py
=====================================
@@ -16,16 +16,16 @@ class Topology:
     """
     if link.is_circular():
       return False
-    if not link.get("from").dovetails_of_end(\
+    if not link.get("from_segment").dovetails_of_end(\
              gfapy.invert(link.from_end.end_type)):
       return True
-    if not link.to.dovetails_of_end(gfapy.invert(link.to_end.end_type)):
+    if not link.to_segment.dovetails_of_end(gfapy.invert(link.to_end.end_type)):
       return True
     c = {}
     for et in ["from", "to"]:
       c[et] = set()
       visited = set()
-      segend = link.get("from") if et == "from" else link.to
+      segend = link.get("from_segment") if et == "from" else link.to_segment
       visited.add(segend.name)
       visited.add(link.other_end(segend).name)
       self.__traverse_component(segend, c[et], visited)


=====================================
gfapy/line/edge/containment/containment.py
=====================================
@@ -17,9 +17,8 @@ class Containment(Containment_ToGFA2, Pos, Canonical, Other,
 
   Note:
     from_segment and to_segment are used instead of from/to
-    as from is not a valid method name in Python. However, when not
-    used as method name (e.g. as argument of get()), from and to can
-    be used, as an alias has been defined.
+    as from is not a valid method name in Python and "to" alone
+    potentially clashes with the tag namespace.
 
   Note:
     The from segment is considered the container, the to segment the contained
@@ -31,8 +30,6 @@ class Containment(Containment_ToGFA2, Pos, Canonical, Other,
                "to_orient", "pos", "overlap"]
   FIELD_ALIAS = {"container" : "from_segment",
                  "contained" : "to_segment",
-                 "from" : "from_segment",
-                 "to" : "to_segment",
                  "container_orient" : "from_orient",
                  "contained_orient" : "to_orient"}
   PREDEFINED_TAGS = ["MQ", "NM", "ID"]


=====================================
gfapy/line/edge/containment/to_gfa2.py
=====================================
@@ -21,7 +21,7 @@ class ToGFA2:
     """
     self._check_overlap()
     rpos = self.pos + self.overlap.length_on_reference()
-    if rpos == self._lastpos_of("from"):
+    if rpos == self._lastpos_of("from_segment"):
       rpos = gfapy.LastPos(rpos)
     return [self.pos, rpos]
 
@@ -30,4 +30,4 @@ class ToGFA2:
     """
     GFA2 positions of the alignment on the **to** segment
     """
-    return [0, self._lastpos_of("to")]
+    return [0, self._lastpos_of("to_segment")]


=====================================
gfapy/line/edge/gfa1/other.py
=====================================
@@ -52,7 +52,7 @@ class Other:
     """
     segment_name = str(segment)
     if segment_name == str(self.from_segment):
-      return self.to
+      return self.to_segment
     elif segment_name == str(self.to_segment):
       return self.from_segment
     elif tolerant:


=====================================
gfapy/line/edge/gfa1/references.py
=====================================
@@ -2,7 +2,7 @@ import gfapy
 
 class References:
   def _initialize_references(self):
-    for d in ["from", "to"]:
+    for d in ["from_segment", "to_segment"]:
       s = self._gfa.segment(self.get(d))
       if s is None:
         if self._gfa._segments_first_order:
@@ -12,13 +12,14 @@ class References:
                                     version = "gfa1",
                                     virtual = True)
         s.connect(self._gfa)
-      self._set_existing_field(d+"_segment", s, set_reference = True)
+      self._set_existing_field(d, s, set_reference = True)
       if self.record_type == "L":
-        et = self.from_end.end_type if d == "from" else self.to_end.end_type
+        et = self.from_end.end_type \
+            if d == "from_segment" else self.to_end.end_type
         key = "dovetails_{}".format(et)
       else:
-        key = \
-          "edges_to_contained" if (d == "from") else "edges_to_containers"
+        key = "edges_to_contained" if (d == "from_segment") \
+              else "edges_to_containers"
       s._add_reference(self, key)
 
   def _import_field_references(self, previous):


=====================================
gfapy/line/edge/gfa1/to_gfa2.py
=====================================
@@ -83,7 +83,7 @@ class ToGFA2:
     length = line.length
     if length is None:
       raise gfapy.ValueError(
-        "Length of segment {} unknown".format(self.to.name))
+        "Length of segment {} unknown".format(self.to_segment.name))
     return gfapy.LastPos(length)
 
   def _check_overlap(self):


=====================================
gfapy/line/edge/gfa2/to_gfa1.py
=====================================
@@ -96,7 +96,8 @@ class ToGFA1:
 
   @from_orient.setter
   def from_orient(self, value):
-    """Set the orientation of the field which will be returned by calling from
+    """Set the orientation of the field which will be returned by calling
+    from_segment
 
     Parameters:
       value (str): one of ["+", "-"]
@@ -119,7 +120,7 @@ class ToGFA1:
 
   @to_segment.setter
   def to_segment(self, value):
-    """Set the field which will be returned by calling ``to``.
+    """Set the field which will be returned by calling ``to_segment``.
 
     Parameters:
       value (str or gfapy.line.segment.GFA2)
@@ -142,7 +143,8 @@ class ToGFA1:
 
   @to_orient.setter
   def to_orient(self, value):
-    """Set the orientation of the field which will be returned by calling ``to``.
+    """Set the orientation of the field which will be returned by calling
+    ``to_segment``.
 
     Parameters:
       value (str): one of ["+", "-"]


=====================================
gfapy/line/edge/link/complement.py
=====================================
@@ -20,7 +20,7 @@ class Complement:
         gfapy.line.edge.Link: The inverted link.
     """
     l = self.clone()
-    l.from_segment = self.to
+    l.from_segment = self.to_segment
     l.from_orient = gfapy.invert(self.to_orient)
     l.to_segment = self.from_segment
     l.to_orient = gfapy.invert(self.from_orient)


=====================================
gfapy/line/edge/link/link.py
=====================================
@@ -19,16 +19,14 @@ class Link(Link_ToGFA2, GFA1_ToGFA2, Link_References, Equivalence, Complement, \
 
   Note:
     from_segment and to_segment are used instead of from/to
-    as from is not a valid method name in Python. However, when not
-    used as method name (e.g. as argument of get()), from and to can
-    be used, as an alias has been defined.
+    as from is not a valid method name in Python and "to" alone
+    potentially clashes with the tag namespace.
   """
 
   RECORD_TYPE = "L"
   POSFIELDS = ["from_segment", "from_orient", "to_segment", "to_orient",
                "overlap"]
   PREDEFINED_TAGS = ["MQ", "NM", "RC", "FC", "KC", "ID"]
-  FIELD_ALIAS = {"from": "from_segment", "to": "to_segment"}
   DATATYPE = {
     "from_segment" : "segment_name_gfa1",
     "from_orient" : "orientation",


=====================================
gfapy/line/edge/link/to_gfa2.py
=====================================
@@ -2,7 +2,7 @@ class ToGFA2:
 
   @property
   def from_coords(self):
-    """GFA2 positions of the alignment on the from segment.
+    """GFA2 positions of the alignment on the **from** segment.
 
     Returns
     -------
@@ -20,7 +20,7 @@ class ToGFA2:
     """
     self._check_overlap()
     if self.from_orient == "+":
-      from_l = self._lastpos_of("from")
+      from_l = self._lastpos_of("from_segment")
       return [from_l - self.overlap.length_on_reference(), from_l]
     else:
       return [0, self.overlap.length_on_reference()]
@@ -32,5 +32,5 @@ class ToGFA2:
     if self.to_orient == "+":
       return [0, self.overlap.length_on_query()]
     else:
-      to_l = self._lastpos_of("to")
+      to_l = self._lastpos_of("to_segment")
       return [to_l - self.overlap.length_on_query(), to_l]


=====================================
setup.py
=====================================
@@ -9,7 +9,7 @@ if not sys.version_info[0] == 3:
   sys.exit("Sorry, only Python 3 is supported")
 
 setup(name='gfapy',
-      version='1.2.1',
+      version='1.2.2',
       description='Library for handling data in the GFA1 and GFA2 formats',
       long_description=readme(),
       url='https://github.com/ggonnella/gfapy',


=====================================
tests/test_api_lines_finders.py
=====================================
@@ -112,20 +112,22 @@ class TestAPILinesFinders(unittest.TestCase):
                                                 "name":"1"}))
     # search links
     self.assertEqual(TestAPILinesFinders.l_gfa1[4:5], TestAPILinesFinders.gfa1.select({"record_type":"L",
-                                                "from":"1",
+                                                "from_segment":"1",
                                                 "from_orient":"+"}))
     # search containments
     self.assertEqual(TestAPILinesFinders.l_gfa1[6:7], TestAPILinesFinders.gfa1.select({"record_type":"C",
-                                                "from":"1",
+                                                "from_segment":"1",
                                                 "pos":1}))
     # search paths
     self.assertEqual(TestAPILinesFinders.l_gfa1[7:8], TestAPILinesFinders.gfa1.select({"record_type":"P",
                                                 "segment_names":"1+,2+"}))
     # no record type specified
     self.assertEqual(TestAPILinesFinders.l_gfa1[0:1], TestAPILinesFinders.gfa1.select({"name":"1"}))
-    self.assertEqual(TestAPILinesFinders.l_gfa1[4:7], TestAPILinesFinders.gfa1.select({"from":"1"}))
+    self.assertEqual(TestAPILinesFinders.l_gfa1[4:7],
+        TestAPILinesFinders.gfa1.select({"from_segment":"1"}))
     # reference as value
-    self.assertEqual(TestAPILinesFinders.l_gfa1[4:7], TestAPILinesFinders.gfa1.select({"from":TestAPILinesFinders.l_gfa1[0]}))
+    self.assertEqual(TestAPILinesFinders.l_gfa1[4:7],
+        TestAPILinesFinders.gfa1.select({"from_segment":TestAPILinesFinders.l_gfa1[0]}))
     # placeholder is equal to any value
     self.assertEqual(set(TestAPILinesFinders.l_gfa1_a[0:3]),
         set([str(x) for x in TestAPILinesFinders.gfa1.select({"sequence":"ACC"})]))


=====================================
tests/test_api_positionals.py
=====================================
@@ -86,7 +86,6 @@ class TestAPIPositionals(unittest.TestCase):
       "S1":{"name":"sid"}, "P":{"path_name":"name"},
       "S2":{"sid":"name"}, "E":{"eid":"name"}, "G":{"gid":"name"},
       "U":{"pid":"name"}, "O":{"pid":"name"},
-      "L":{"from_segment": "from", "to_segment": "to"},
       "C":{"from_segment":"container", "from_orient":"container_orient",
              "to_segment":"contained", "to_orient":"contained_orient"}
   }


=====================================
tests/test_unit_line_connection.py
=====================================
@@ -62,10 +62,10 @@ class TestUnitLineConnection(unittest.TestCase):
     g = gfapy.Gfa()
     g.append(s1)
     g.append(l)
-    assert(l.get("from") is s1)
+    assert(l.get("from_segment") is s1)
     l.disconnect()
-    assert(not l.get("from") is s1)
-    self.assertEqual("1", l.get("from"))
+    assert(not l.get("from_segment") is s1)
+    self.assertEqual("1", l.get("from_segment"))
 
   def test_disconnect_disconnects_depent_lines(self):
     s1 = gfapy.Line("S\t1\tACCAT")


=====================================
tests/test_unit_line_dynamic_fields.py
=====================================
@@ -8,8 +8,8 @@ class TestUnitLineDynamicFields(unittest.TestCase):
     # record_type
     self.assertTrue(hasattr(l, "record_type"))
     # reqfields
-    self.assertTrue(hasattr(l, "from"))
-    self.assertIsInstance(object.__getattribute__(l, "from"),
+    self.assertTrue(hasattr(l, "from_segment"))
+    self.assertIsInstance(object.__getattribute__(l, "from_segment"),
                           gfapy.line.common.dynamic_fields.DynamicField)
     # predefined tags
     self.assertTrue(hasattr(l, "KC"))


=====================================
tests/test_unit_line_equivalence.py
=====================================
@@ -94,7 +94,8 @@ class TestUnitLineEquivalence(unittest.TestCase):
     assert(TestUnitLineEquivalence.a._has_eql_fields(TestUnitLineEquivalence.a.clone()))
     # positional field difference
     assert(not TestUnitLineEquivalence.l._has_eql_fields(TestUnitLineEquivalence.l_from))
-    assert(TestUnitLineEquivalence.l._has_eql_fields(TestUnitLineEquivalence.l_from, ["from"]))
+    assert(TestUnitLineEquivalence.l._has_eql_fields(TestUnitLineEquivalence.l_from,
+      ["from_segment"]))
     # positional field difference: name alias
     assert(not TestUnitLineEquivalence.e._has_eql_fields(TestUnitLineEquivalence.e_name))
     assert(TestUnitLineEquivalence.e._has_eql_fields(TestUnitLineEquivalence.e_name, ["eid"]))



View it on GitLab: https://salsa.debian.org/med-team/gfapy/-/commit/d6805080f3fc41ca93ecd5bcee5f40378d6012f7

-- 
View it on GitLab: https://salsa.debian.org/med-team/gfapy/-/commit/d6805080f3fc41ca93ecd5bcee5f40378d6012f7
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220121/b31fb719/attachment-0001.htm>


More information about the debian-med-commit mailing list