Two-way correspondence between carbon nanotubes and caps: Development of a numerical algorithm and a tool for organic cap synthesis