From OpenWetWare

(Difference between revisions)
Jump to: navigation, search

TChan (Talk | contribs)
(New page: =Revision of 'Output Useful Patient Info' code= <pre> SAMPLE INPUT: disease name, as string Note: code will handle disease names with spaces, as well as apostrophes (ex. """Hashimoto's Thy...)
Next diff →

Revision as of 16:11, 2 May 2007

Revision of 'Output Useful Patient Info' code

SAMPLE INPUT: disease name, as string
Note: code will handle disease names with spaces, as well as apostrophes (ex. """Hashimoto's Thyroiditis""")
CODE (revised W 5.2.07 for efficiency):

import urllib

# Definitions of functions

def parse_for_MedStory_genl(search_term):
    parsed_term = search_term.lower().replace("'", '%27').replace(' ', '+')
    return "" % parsed_term

def get_MedStory_search_file(search_term, genl_search_file):
    URL_stream_genl = urllib.urlopen(parse_for_MedStory_genl(search_term))
    page =

def get_MedStory_data(drug_list, procedure_list, experts_list, clinical_list, search_file):
    for line in search_file:
        if line.find('''_Drug">''') != -1:
        elif line.find('''_Therapy">''') != -1:
        elif line.find('''_Person">''') != -1:
        elif line.find('''_ExperimentalDrug">''') != -1:
    return drug_list, procedure_list, experts_list, clinical_list

# Functions that parse the search_term to display relevant URLs

def parse_for_MedStory_clinical(search_term):
    parsed_term = search_term.lower().replace("'", '%27').replace(' ', '+')
    return "" % parsed_term

def parse_for_eMed(search_term):
    parsed_term = search_term.lower().replace(' ', '%20')
    return "" % parsed_term

def parse_for_Google_genl(search_term):
    parsed_term = search_term.lower().replace("'", '%27').replace(' ', '+')
    return "" % parsed_term 

def parse_for_Google_treatment(search_term):
    parsed_term = search_term.lower().replace("'", '%27').replace(' ', '+')
    return "" % parsed_term

def parse_for_Wikipedia(search_term):
    parsed_term = search_term.lower().capitalize().replace("'", '%27').replace(' ', '_')
    return "" % parsed_term

def parse_for_WHO(search_term):
    parsed_term = search_term.lower().replace("'", '%27').replace(' ', '+')
    return "" % parsed_term

def parse_for_GeneCards(search_term):
    parsed_term = search_term.lower().replace(" ", '+')
    # NB: This only gives a functionally correct search if the search_term is a name of a disease
    # because there are other formats for different inputs and different forms of the input
    return "" % parsed_term

def return_site_list_for_disease(search_term):
    # Currently returns site-name and URL list
    # ex. [["eMedicine", ""]]
    return [["MedStory, clinical trials", parse_for_MedStory_clinical(search_term)],
            ["eMedicine", parse_for_eMed(search_term)],
            ["Google, general search", parse_for_Google_genl(search_term)],
            ["Google, Treatment search", parse_for_Google_treatment(search_term)],
            ["Wikipedia", parse_for_Wikipedia(search_term)],
            ["WHO", parse_for_WHO(search_term)],
            ["GeneCards", parse_for_GeneCards(search_term)]]

# Stuff actually happening in the program
search_term = """Hashimoto's Thyroiditis"""     # example search_term for now; will be returned by rest of program when finished    
search_file_name = "%s_medstory.html" % search_term

medstory_file = open(search_file_name, 'w')
get_MedStory_search_file(search_term, medstory_file)

drug_list = []
procedure_list = []
experts_list = []
clinical_list = []      # refers to drugs currently in clinical trials

#Build lists of MedStory data
search_file = open(search_file_name, 'r')
drug_list, procedure_list, experts_list, clinical_list = get_MedStory_data(drug_list, procedure_list, experts_list, clinical_list, search_file)

#Build list of relevant URLs
final_list = []
final_list = return_site_list_for_disease(search_term)

#Print all data 
print drug_list
print procedure_list
print experts_list
print clinical_list

print final_list


['Ifex', 'Adriamycin', 'Methotrexate', 'Platinol', 'Neutrexin']
['Chemotherapy', 'Neoadjuvant Chemo...', 'Adjuvant Chemothe...', 'Radiation Therapy', 'Biopsy']
['Meyers, Paul A', 'Gorlick, Richard', 'Daw, Najat C', 'Gearen, Peter F', 'Geoerger, Birgit']
['Slit Cisplatin', 'Ap23573', 'Trabectedin', 'VP-16', 'Dasatinib']
[['MedStory, clinical trials', ''], 
['eMedicine', ''], 
['Google, general search', ''], 
['Google, Treatment search', ''], 
['Wikipedia', ''], ['WHO', ''], 
['GeneCards', '']]

Personal tools