PhyloStar / CogDetect

A lightweight library for cognate clustering, converting IPA sequences to sound classes, computing distances between languages
2 stars 1 forks source link

Improve local alignment function #23

Open Anaphory opened 7 years ago

Anaphory commented 7 years ago

(As remarked by @LinguList in https://github.com/PhyloStar/CogDetect/pull/22#discussion_r115956831)

Currently, the local keyword in distances.needleman_wunsch comes from an afterthought/experiment with local alignment, and while it works, the return value neglects to mention the prefix and suffix parts that were not aligned.

In order to not give the function different return values depending on a keyword argument, we should consider splitting that behaviour out to a different function (smith_waterman?) which then returns all of those values.

Re-using code may be easiest if the core (ll. 106–122 currently) is exported into a separate calculate_alignment_scores function?

Anaphory commented 7 years ago

Alternatively, don't re-implement the wheel and look at eg. lingpy's various alignment methods and use the needleman_wunsch (Code in lingpy.algorithm.cython._malign.nw_align) and other alignment methods from there.