Should I apply again to the same research group where I used to work and haven't got any PhD offer from the professor? Approximately a couple of years ago I was working in a Computer Science project abroad. The task was to implement a software analysis tool with the collaboration of a professor, and if all went well then I could get a PhD position at one of their departments.

Well after expending like half of the year on the project, due to some personal problems that did not allow me to focus entirely on the programming task, ie. taking care of my old parents, it was that the project suffered a delay.

When I was about to end the project and got some finishing results, the research was published in another country by other university. It seems here that the phrase "publish or perish" was more real than ever. Because of that reason the professor in charge did not offer me the PhD position, so I was some sort sad about it.

I have the inner feeling that I could have done better to get that position, so I don't know if I should ask to the professor in charge if he could give me another chance. Maybe if I do that I will bury myself academically, but I don't know what to do.

Any advice?
You got scooped. That sucks, but it happens a lot; and it is definitely not the end of the world.

If you think your work was good in the group, I would say go ahead and apply. You could explain to him why the project was delayed; a polite discussion cannot possibly hurt you, and you can figure out in which terms they are with you. Remember that even if you were in your best conditions, some other group may have just more people working on the same problem, or they started one year before you, or any other reason.

By the way, you have now a working implementation of the analysis, and perhaps you can improve it to do something the other group didn't; implement other algorithms, etc.