ragtag_utilities/ScaffoldGraph.py
def _get_assembly_points(self, agp, weight):
        """
        Find all adjacencies defined in an AGP file
        :param agp: An AGP file defining sequence adjacencies
        :param weight: The weight to assign to each adjacency
        """
        comps = set()
        prev_obj = ""
        seq1 = ""
        strand1 = ""

        # Gap info
        gap_count = 0
        prev_agp_known = None
        prev_gap_size = 0
        prev_gap_type = None
        prev_linkage = ""
        prev_evidence = ""

        # Iterate over the AGP file and yield assembly points
        agp_file = AGPFile(agp)
        for agp_line in agp_file.iterate_lines():
            if not agp_line.is_gap:
                # Add this component to our master list
                if agp_line.comp not in self.component_lens:
                    raise RuntimeError("{} is in {} but not {}.".format(agp_line.comp, agp, self.components_fasta_fname))
                comps.add(agp_line.comp)

                comp_len = agp_line.comp_end
                if comp_len < self.get_component_len(agp_line.comp):
                    raise RuntimeError("only complete components can be added to the graph.")

                if comp_len > self.get_component_len(agp_line.comp):
                    raise RuntimeError("inconsistent component lengths: {} bp in {} and {} bp in {}". format(comp_len, agp, self.get_component_len(agp_line.comp), self.components_fasta_fname))

                if agp_line.obj == prev_obj:
                    # Check if these components are bookended (no gap in between)
                    if not gap_count:
                        prev_evidence = "bookend"

                    # Check if two consecutive gaps preceded this component
                    if gap_count > 1:
                        raise ValueError("Consecutive gaps in the AGP file are not currently supported.")

                    yield AssemblyPoint(
                        seq1,
                        strand1,
                        agp_line.comp,
                        agp_line.orientation,
                        weight,
                        agp,
                        prev_agp_known,
                        prev_gap_size,
                        prev_gap_type,
                        prev_linkage,
                        prev_evidence
                    )

                    # Set this component as the previous component
                    seq1 = agp_line.comp
                    strand1 = agp_line.orientation

                    gap_count = 0
                    prev_agp_known = None
                    prev_gap_size = 0
                    prev_gap_type = None
                    prev_linkage = ""
                    prev_evidence = ""

                else:
                    seq1 = agp_line.comp
                    strand1 = agp_line.orientation

                    prev_obj = agp_line.obj
                    gap_count = 0
                    prev_agp_known = None
                    prev_gap_size = 0
                    prev_gap_type = None
                    prev_linkage = ""
                    prev_evidence = ""
            else:
                if agp_line.obj == prev_obj:
                    gap_count += 1
                    prev_agp_known = True if agp_line.comp_type == "N" else False
                    prev_gap_size = agp_line.gap_len
                    prev_gap_type = agp_line.gap_type
                    prev_linkage = True if agp_line.linkage == "yes" else False
                    prev_evidence = agp_line.linkage_evidence

        if comps != self.components:
            raise ValueError("Input AGPs do not have the same set of components.")

        Find all adjacencies defined in an AGP file
        :param agp: An AGP file defining sequence adjacencies
        :param weight: The weight to assign to each adjacency
        
Find all adjacencies defined in an AGP file
Find all adjacencies defined in an AGP file
def _get_assembly_points(self, agp, weight):
        comps = set()
        prev_obj = ""
        seq1 = ""
        strand1 = ""
        gap_count = 0
        prev_agp_known = None
        prev_gap_size = 0
        prev_gap_type = None
        prev_linkage = ""
        prev_evidence = ""
        agp_file = AGPFile(agp)
        for agp_line in agp_file.iterate_lines():
            if not agp_line.is_gap:
                if agp_line.comp not in self.component_lens:
                    raise RuntimeError("{} is in {} but not {}.".format(agp_line.comp, agp, self.components_fasta_fname))
                comps.add(agp_line.comp)
                comp_len = agp_line.comp_end
                if comp_len < self.get_component_len(agp_line.comp):
                    raise RuntimeError("only complete components can be added to the graph.")
                if comp_len > self.get_component_len(agp_line.comp):
                    raise RuntimeError("inconsistent component lengths: {} bp in {} and {} bp in {}". format(comp_len, agp, self.get_component_len(agp_line.comp), self.components_fasta_fname))
                if agp_line.obj == prev_obj:
                    if not gap_count:
                        prev_evidence = "bookend"
                    if gap_count > 1:
                        raise ValueError("Consecutive gaps in the AGP file are not currently supported.")
                    yield AssemblyPoint(
                        seq1,
                        strand1,
                        agp_line.comp,
                        agp_line.orientation,
                        weight,
                        agp,
                        prev_agp_known,
                        prev_gap_size,
                        prev_gap_type,
                        prev_linkage,
                        prev_evidence
                    )
                    seq1 = agp_line.comp
                    strand1 = agp_line.orientation
                    gap_count = 0
                    prev_agp_known = None
                    prev_gap_size = 0
                    prev_gap_type = None
                    prev_linkage = ""
                    prev_evidence = ""
                else:
                    seq1 = agp_line.comp
                    strand1 = agp_line.orientation
                    prev_obj = agp_line.obj
                    gap_count = 0
                    prev_agp_known = None
                    prev_gap_size = 0
                    prev_gap_type = None
                    prev_linkage = ""
                    prev_evidence = ""
            else:
                if agp_line.obj == prev_obj:
                    gap_count += 1
                    prev_agp_known = True if agp_line.comp_type == "N" else False
                    prev_gap_size = agp_line.gap_len
                    prev_gap_type = agp_line.gap_type
                    prev_linkage = True if agp_line.linkage == "yes" else False
                    prev_evidence = agp_line.linkage_evidence
        if comps != self.components:
            raise ValueError("Input AGPs do not have the same set of components.")
def _get_assembly_points ( self , agp , weight ) : comps = set ( ) prev_obj = "" seq1 = "" strand1 = "" gap_count = 0 prev_agp_known = None prev_gap_size = 0 prev_gap_type = None prev_linkage = "" prev_evidence = "" agp_file = AGPFile ( agp ) for agp_line in agp_file . iterate_lines ( ) : if not agp_line . is_gap : if agp_line . comp not in self . component_lens : raise RuntimeError ( "{} is in {} but not {}." . format ( agp_line . comp , agp , self . components_fasta_fname ) ) comps . add ( agp_line . comp ) comp_len = agp_line . comp_end if comp_len < self . get_component_len ( agp_line . comp ) : raise RuntimeError ( "only complete components can be added to the graph." ) if comp_len > self . get_component_len ( agp_line . comp ) : raise RuntimeError ( "inconsistent component lengths: {} bp in {} and {} bp in {}" . format ( comp_len , agp , self . get_component_len ( agp_line . comp ) , self . components_fasta_fname ) ) if agp_line . obj == prev_obj : if not gap_count : prev_evidence = "bookend" if gap_count > 1 : raise ValueError ( "Consecutive gaps in the AGP file are not currently supported." ) yield AssemblyPoint ( seq1 , strand1 , agp_line . comp , agp_line . orientation , weight , agp , prev_agp_known , prev_gap_size , prev_gap_type , prev_linkage , prev_evidence ) seq1 = agp_line . comp strand1 = agp_line . orientation gap_count = 0 prev_agp_known = None prev_gap_size = 0 prev_gap_type = None prev_linkage = "" prev_evidence = "" else : seq1 = agp_line . comp strand1 = agp_line . orientation prev_obj = agp_line . obj gap_count = 0 prev_agp_known = None prev_gap_size = 0 prev_gap_type = None prev_linkage = "" prev_evidence = "" else : if agp_line . obj == prev_obj : gap_count += 1 prev_agp_known = True if agp_line . comp_type == "N" else False prev_gap_size = agp_line . gap_len prev_gap_type = agp_line . gap_type prev_linkage = True if agp_line . linkage == "yes" else False prev_evidence = agp_line . linkage_evidence if comps != self . components : raise ValueError ( "Input AGPs do not have the same set of components." )
Find all adjacencies defined in an AGP file
Find all adjacencies defined in an AGP file
"""
        Find all adjacencies defined in an AGP file
        :param agp: An AGP file defining sequence adjacencies
        :param weight: The weight to assign to each adjacency
        """ # Gap info # Iterate over the AGP file and yield assembly points # Add this component to our master list # Check if these components are bookended (no gap in between) # Check if two consecutive gaps preceded this component # Set this component as the previous component
self
agp
An AGP file defining sequence adjacencies
An AGP file defining sequence adjacencies
weight
The weight to assign to each adjacency
The weight to assign to each adjacency