kp is right, you cannot always judge by color, as sometimes somebody has been there ahead of you and the may not have wired things correctly.
But, in a perfect world, they are as follows:
On the fan- black is fan power in (hot), white is neutral, blue is hot for a fan light kit, and green is ground.
In your home- black is hot, white is neutral, and bare copper is ground. The presence of the red is probably an indication that this light fixture box is controlled from 2 places by 3-way switches.
The 2 blacks could be just a junction, or it could be the power coming from the switches. The black and red is probably a junction feeding power between the switches, but it might also be the power FROM the switches.
I would get knowledgeable assistance for this one, Kerry.