How to programatically detect if a custom module is installed?

How to programatically detect if a custom module is installed? I have 2 optional modules called pricelines and custom_pricing. A separate custom modification, found in custom/modules/Quotes/clients/base/views/record/record.js handles changing billing accounts and currencies. Now, the above mentioned 2 modules are account specific and affect the quoted line items. So if I change the billing account I need to reset or adjust the quoted line items. Obviously I can not simply query the system to get the corresponding info (aka discounts) from the 2 modules, because as I mentioned those are OPTIONAL. So if the module is not installed, such and operation will result in a fatal error. Thus I need something like this:

if (module_installed)
{
do_query
}

Is there something in sugar to help me out?