Changes orientation of each contig to match the reference, when possible.
           Returns a set of names of contigs that had hits in both orientations to the reference
324821
def _fix_contig_orientation(contigs_fa, ref_fa, outfile, min_id=90, min_length=20, breaklen=200):
        ''''''
        if not os.path.exists(contigs_fa):
            raise Error('Cannot fix orientation of assembly contigs because file not found: ' + contigs_fa)

        tmp_coords = os.path.join(outfile + '.tmp.rename.coords')
        pymummer.nucmer.Runner(
            ref_fa,
            contigs_fa,
            tmp_coords,
            min_id=min_id,
            min_length=min_length,
            breaklen=breaklen,
            maxmatch=True,
        ).run()

        to_revcomp = set()
        not_revcomp = set()
        file_reader = pymummer.coords_file.reader(tmp_coords)
        for hit in file_reader:
            if hit.on_same_strand():
                not_revcomp.add(hit.qry_name)
            else:
                to_revcomp.add(hit.qry_name)

        os.unlink(tmp_coords)
        in_both = to_revcomp.intersection(not_revcomp)

        f = pyfastaq.utils.open_file_write(outfile)
        seq_reader = pyfastaq.sequences.file_reader(contigs_fa)
        for seq in seq_reader:
            if seq.id in to_revcomp and seq.id not in in_both:
                seq.revcomp()
            print(seq, file=f)
        pyfastaq.utils.close(f)

        return in_both
728291
@Override
    void findReferencedClassNames(final Set<String> referencedClassNames) {
        if (enumValue != null) {
            enumValue.findReferencedClassNames(referencedClassNames);
        } else if (classRef != null) {
            referencedClassNames.add(classRef.getClassName());
        } else if (annotationInfo != null) {
            annotationInfo.findReferencedClassNames(referencedClassNames);
        } else if (objectArrayValue != null) {
            for (final ObjectTypedValueWrapper item : objectArrayValue) {
                item.findReferencedClassNames(referencedClassNames);
            }
        }
    }
548396
def nucmer_hits_to_ref_and_qry_coords(cls, nucmer_hits, contig=None):
        ''''''
        if contig is None:
            ctg_coords = {key: [] for key in nucmer_hits.keys()}
        else:
            ctg_coords = {contig: []}

        ref_coords = {}

        for key in ctg_coords:
            hits = copy.copy(nucmer_hits[key])
            hits.sort(key=lambda x: len(x.ref_coords()))

            if len(hits) > 1:
                i = 0
                while i < len(hits) - 1:
                    c1 = hits[i].ref_coords()
                    c2 = hits[i+1].ref_coords()
                    if c2.contains(c1):
                        hits.pop(i)
                    else:
                        i += 1

            ref_coords[key] = [hit.ref_coords() for hit in hits]
            ctg_coords[key] = [hit.qry_coords() for hit in hits]
            pyfastaq.intervals.merge_overlapping_in_list(ref_coords[key])
            pyfastaq.intervals.merge_overlapping_in_list(ctg_coords[key])

        return ctg_coords, ref_coords
868648
private void checkCircularReference(final BeanId... references) {
        for (BeanId beanId : references) {
            if (getId().equals(beanId)) {
                throw CFG310_CIRCULAR_REF(getId(), getId());
            }
        }
    }
503687
def align_to_other(self, other, mapping, self_root_pair, other_root_pair = None):
        '''
        
        '''
        if other_root_pair == None:
            other_root_pair = self_root_pair

        assert( len(self_root_pair) == len(other_root_pair) )

        unmoved_atom_names = []
        new_coords = [ None for x in xrange( len(self_root_pair) ) ]
        for atom in self.names:
            if atom in self_root_pair:
                i = self_root_pair.index(atom)
                assert( new_coords[i] == None )
                new_coords[i] = self.get_coords_for_name(atom)

            if atom in mapping:
                other_atom = mapping[atom]
                self.set_coords_for_name( atom, other.get_coords_for_name(other_atom) )
            else:
                unmoved_atom_names.append(atom)

        # Move unmoved coordinates after all other atoms have been moved (so that
        # references will have been moved already)
        if None in new_coords:
            print new_coords
            assert( None not in new_coords )
        ref_coords = [other.get_coords_for_name(x) for x in other_root_pair]

        # Calculate translation and rotation matrices
        U, new_centroid, ref_centroid = calc_rotation_translation_matrices( ref_coords, new_coords )
        for atom in unmoved_atom_names:
            original_coord = self.get_coords_for_name(atom)
            self.set_coords_for_name( atom, rotate_and_translate_coord(original_coord, U, new_centroid, ref_centroid) )
        self.chain = other.chain
315504
def _coordinates_changed(self):
        """"""
        if self._are_coordinates_valid():
            point1 = QgsPointXY(
                self.x_minimum.value(),
                self.y_maximum.value())
            point2 = QgsPointXY(
                self.x_maximum.value(),
                self.y_minimum.value())
            rect = QgsRectangle(point1, point2)

            self.tool.set_rectangle(rect)
97155
def fields(self):
        '''
        
        '''
        return (
            self.locus, self.offset_start, self.offset_end, self.alignment_key)
943809
def setKWARGS(self, **kwargs):
        
        for key in list(kwargs.keys()):
            #try:
            f = getattr(self,'set_' + key)
            f(kwargs[key])
251155
def _initialized_adjustments(self, prstGeom):
        
        if prstGeom is None:
            return []
        davs = AutoShapeType.default_adjustment_values(prstGeom.prst)
        adjustments = [Adjustment(name, def_val) for name, def_val in davs]
        self._update_adjustments_with_actuals(adjustments, prstGeom.gd_lst)
        return adjustments
358650
def swapaxes(self, axis1, axis2, copy=True):
        
        i = self._get_axis_number(axis1)
        j = self._get_axis_number(axis2)

        if i == j:
            if copy:
                return self.copy()
            return self

        mapping = {i: j, j: i}

        new_axes = (self._get_axis(mapping.get(k, k))
                    for k in range(self._AXIS_LEN))
        new_values = self.values.swapaxes(i, j)
        if copy:
            new_values = new_values.copy()

        return self._constructor(new_values, *new_axes).__finalize__(self)
102449
def _init_orient(self):
        
        if self.orient == orientation.orient_averaged_fixed:
            (self.beta_p, self.beta_w) = quadrature.get_points_and_weights(
                self.or_pdf, 0, 180, self.n_beta)
        self._set_orient_signature()
418485
def getnamedargs(*args, **kwargs):
    """"""
    adict = {}
    for arg in args:
        if isinstance(arg, dict):
            adict.update(arg)
    adict.update(kwargs)
    return adict
350798
public Set<String> getConstantNames() {
        return constants.stream()
                .map(EnumConstant::getName)
                .collect(Collectors.toSet());
    }
941177
def target_names(targets):
    """"""
    names = []
    for entry in targets:
        if isinstance(entry, ast.Name):
            names.append(entry.id)
        elif isinstance(entry, ast.Tuple):
            for element in entry.elts:
                if isinstance(element, ast.Name):
                    names.append(element.id)

    return names
14759
def _on_axes_updated(self):
        
        # update attrs
        self.attrs["axes"] = [a.identity.encode() for a in self._axes]
        # remove old attributes
        while len(self._current_axis_identities_in_natural_namespace) > 0:
            key = self._current_axis_identities_in_natural_namespace.pop(0)
            try:
                delattr(self, key)
            except AttributeError:
                pass  # already gone
        # populate new attributes
        for a in self._axes:
            key = a.natural_name
            setattr(self, key, a)
            self._current_axis_identities_in_natural_namespace.append(key)
187359
def _make_circularised_contig(self, ref_start_hit, ref_end_hit):
        ''''''
        assert ref_start_hit.ref_name == ref_end_hit.ref_name
        assert ref_start_hit.qry_name == ref_end_hit.qry_name


        qry_name = ref_start_hit.qry_name
        ref_name = ref_start_hit.ref_name
        ref_start_coords = ref_start_hit.ref_coords()
        ref_end_coords = ref_end_hit.ref_coords()

        if ref_start_coords.intersects(ref_end_coords):
            new_ctg = copy.copy(self.reassembly_contigs[qry_name])
            new_ctg.id = ref_name
            return new_ctg

        if ref_start_hit.on_same_strand():
            qry_start_coords = ref_end_hit.qry_coords()
            qry_end_coords = ref_start_hit.qry_coords()
            bases = self.original_contigs[ref_name][ref_start_coords.end+1:ref_end_coords.start] + \
                    self.reassembly_contigs[qry_name][qry_start_coords.start:qry_end_coords.end+1]
            return pyfastaq.sequences.Fasta(ref_name, bases)
        else:
            qry_start_coords = ref_start_hit.qry_coords()
            qry_end_coords = ref_end_hit.qry_coords()
            tmp_seq = pyfastaq.sequences.Fasta('x', self.reassembly_contigs[qry_name][qry_start_coords.start:qry_end_coords.end+1])
            tmp_seq.revcomp()
            return pyfastaq.sequences.Fasta(ref_name, self.original_contigs[ref_name][ref_start_coords.end+1:ref_end_coords.start] + tmp_seq.seq)
760474
private void changePoseToReference() {
		Se3_F64 keyToCurr = currToKey.invert(null);

		List<PointTrack> all = trackerLeft.getAllTracks(null);

		for( PointTrack t : all ) {
			LeftTrackInfo p = t.getCookie();
			SePointOps_F64.transform(keyToCurr, p.location.location, p.location.location);
		}

		concatMotion();
	}