I´m creating a phylogenetic tree algorithm that will classify species according it's beta globine of hemoglobin and sequences, but I' don't know how to deal with sequences of different lengths.
You may explore Phylip (https://evolution.genetics.washington.edu/phylip.html) for ideas about the available methods. here you can find how to calculate the distance between sequences and construct the phylogenetic tree.
The goal of the tree building is to distinguish homologous sites that join organisms from those the split them.
So intuitively you know that sites that have only one or two sequences cannot be phylogenetically informative. Hence you might as well trim the alignment at the point that no phylogenetic data.
On the other hand, a likelihood method, for example calculates the likelihoods of each site in the alignment and then sums the site likelihoods to give the likelihood score of the inferred tree. Any site that does not have much information will necessarily have a low likelihood score so will not contribute very much to the overall score so, in a sense, these sites have little influence on the likelihood tree.
There is a large literature that describes the pitfalls of uneven lengths. I tend to think that leaving some sparse sites in the alignment will at least contribute the likelihood of any phylogenetic patterns among the taxa that are included. This is arguable, however.