BRCAness has important implications in the management and treatment of patients with breast and ovarian cancer. In this study, we propose a computational framework to measure the BRCAness of breast and ovarian tumor samples based on their gene expression profiles. We define a characteristic profile for BRCAness by comparing gene expression differences between BRCA1/2 mutant familial tumors and sporadic breast cancer tumors while adjusting for relevant clinical factors. With this BRCAness profile, our framework calculates sample-specific BRCA scores, which indicates homologous recombination (HR)-mediated DNA repair pathway activity of samples. We found that in sporadic breast cancer high BRCAness score is associated with aberrant copy number of HR genes rather than somatic mutation and other genomic features. Moreover, we observed significant correlations of BRCA score with genome instability and neoadjuvant chemotherapy. More importantly, BRCA score provides significant prognostic value in both breast and ovarian cancers after considering established clinical variables. In summary, the inferred BRCAness from our framework can be used as a robust biomarker for the prediction of prognosis and treatment response in breast and ovarian cancers.