Science is definitely calculated first (or very early) in a turn.
An example from one of my games recently:
The Vikings finished Newton's when I had 1 turn left to Sci Meth. I left the Newton's prebuild I had going, and hit next turn. Normally, the game will change the build for you the turn after something is completed, but when I got the advance, I went into 'big picture' and changed the build to ToE BEFORE it did the city check, thus not losing the shields.
Whenever I lose a galley, I lose it AFTER it has done all the city builds, but before I can move, implying it is one of the last things calculated. I can't speak from specific experience, but I would make a confident guess that the galley will survive on the sea square.
BTW - a related side note: I have noticed that when you are starving a city down, if you change all the citizens to scientists, you DO get the beakers added to your total. I checked by making it so one less scientist would cause me to get the advance a turn later, and having a few cities on science starvation diets. I did get the advance.
I point this out because it has been noted here a couple times lately that using taxmen to starve the city gets you no benefit, as the citizens are rearranged after starvation, but before the gold is calculated.