#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    63
    Rep Power
    2

    Request to provide changes in code according to output


    Hi all

    I have attached my sample input file and sample expected output file from my big files.

    I am using following code but there are certain changes which has to be made to completely get expected output

    PHP Code:
    #!/usr/bin/perl -w 

    use strict

    if ($
    #ARGV < 1) { 
    print "Usage: $0 input_file output_file\n"
    exit 
    0


    my $input_file $ARGV[0]; 
    my $output_file $ARGV[1]; 

    my $prev_ttds_num ''
    my @diseases = (); 
    my $drug_name ''

    open my $IFH'<'$input_file or die "$!\n"
    open my $OFH'>'$output_file or die "$!\n"

    while (
    my $line = <$IFH>) { 
    chomp $line
    next if $line eq ''
    my @array = split /\t/, $line

    my $ttds_num shift @array; 
    my $rec_type shift @array; 

    if (
    $ttds_num ne $prev_ttds_num) { 
    if (
    $prev_ttds_num ne '') { 
    dump_data($OFH$drug_name, \@diseases); 

    $prev_ttds_num $ttds_num
    @
    diseases = (); 
    $drug_name ''


    if (
    $rec_type eq 'Name') { 
    $drug_name shift @array; 

    elsif ($rec_type eq 'Drug(s)') { 
    my $part_record join("\t", @array); 
    push @diseases$part_record



    dump_data($OFH$drug_name, \@diseases); 
    close $OFH
    close $IFH

    print 
    "Done\n"
    exit 
    0

    ###################################################################### 
    # # 
    # S U B R O U T I N E S # 
    # # 
    ###################################################################### 

    ##  
    # @brief Routine to dump out multiple records 
    # @param FH - A file handle to write data out 
    # @param drug_name - The name of the drug 
    # @param disease_ref - An array references to list of disease data 
    # @return undef 

    sub dump_data 
    my ($FH$drug_name$disease_ref) = @_
    return if (
    $drug_name eq ''); 

    foreach 
    my $disease (@{ $disease_ref }) { 
    print ${
    FH"$drug_name\t$disease\n"


    return; 

    In my attached files

    input is:

    PHP Code:
    TTDS00002    UniProt ID    P11229
    TTDS00002    Name    Muscarinic acetylcholine receptor M1
    TTDS00002    Type of target    Successful target
    TTDS00002    Synonyms    M1 receptor
    TTDS00002    Disease    Alzheimer
    's disease
    TTDS00002    Disease    Bronchospasm (histamine induced)
    TTDS00002    Disease    Cognitive deficits
    TTDS00002    Disease    Schizophrenia
    TTDS00002    Function    The muscarinic acetylcholine receptor mediates various cellular responses, including inhibition of adenylate cyclase, breakdown of phosphoinositides and modulation of potassium channels through the action of G proteins.
    TTDS00002    Sequence    MNTSAPPAVSPNITVLAPGKGPWQVAFIGITTGLLSLATVTGNLLVLISFKVNTELKTVNNYFLLSLACADLIIGTFSMNLYTTYLLMGHWALGTLACDLWLALDYVASNASVMNLLLISFDRYFSVTRPLSYRAKRTPRRAALMIGLAWLVSFVLWAPAILFWQYLVGERTVLAGQCYIQFLSQPIITFGTAMAAFYLPVTVMCTLYWRIYRETENRARELAALQGSETPGKGGGSSSSSERSQPGAEGSPETPPGRCCRCCRAPRLLQAYSWKEEEEEDEGSMESLTSSEGEEPGSEVVIKMPMVDPEAQAPTKQPPRSSPNTVKRPTKKGRDRAGKGQKPRGKEQLAKRKTFSLVKEKKAARTLSAILLAFILTWTPYNIMVLVSTFCKDCVPETLWELGYWLCYVNSTINPMCYALCNKAFRDTFRLLLLCRWDKRRWRKIPKRPGSVHRTPSRQC
    TTDS00002    BioChemical Class    G-protein coupled receptor (rhodopsin family)
    TTDS00002    Pathway    Calcium signaling pathway
    TTDS00002    Pathway    Neuroactive ligand-receptor interaction
    TTDS00002    Pathway    Regulation of actin cytoskeleton
    TTDS00002    Related US Patent    6,288,068
    TTDS00002    Related US Patent    6,294,554
    TTDS00002    Related US Patent    6,627,645
    TTDS00002    Drug(s)    Pirenzepine    DAP000492    Peptic ulcer disease    Approved
    TTDS00002    Drug(s)    Glycopyrrolate    DAP001116    Anesthetic    Approved
    TTDS00002    Drug(s)    Clidinium    DAP001117    Abdominal/stomach pain    Approved
    TTDS00002    Drug(s)    Dicyclomine    DAP001118    Irritable bowel syndrome    Approved
    TTDS00002    Drug(s)    Ethopropazine    DAP001119    Parkinson'
    s disease    Approved
    TTDS00002    Drug
    (s)    Cycrimine    DAP001120    Parkinson's disease    Approved
    TTDS00002    Drug(s)    Benztropine    DAP001121    Parkinson'
    s disease    Approved
    TTDS00002    Drug
    (s)    Trihexyphenidyl    DAP001122    Parkinson's disease    Approved
    TTDS00002    Drug(s)    Propantheline    DAP001123    Excessive sweating (hyperhidrosis)    Approved
    TTDS00002    Drug(s)    Oxyphenonium    DAP001124    Spasm    Approved
    TTDS00002    Drug(s)    Biperiden    DAP001125    Parkinson'
    s disease    Approved
    TTDS00002    Antagonist    Pirenzepine    DAP000492
    TTDS00002    Antagonist    Glycopyrrolate    DAP001116
    TTDS00002    Antagonist    Clidinium    DAP001117
    TTDS00002    Antagonist    Dicyclomine    DAP001118
    TTDS00002    Antagonist    Ethopropazine    DAP001119
    TTDS00002    Antagonist    Benztropine    DAP001121
    TTDS00002    Antagonist    Trihexyphenidyl    DAP001122
    TTDS00002    Antagonist    Propantheline    DAP001123
    TTDS00002    Antagonist    Oxyphenonium    DAP001124
    TTDS00002    Antagonist    Biperiden    DAP001125
    TTDS00002    Binder    Cycrimine    DAP001120 
    And output is

    PHP Code:
    P11229    M1 receptor    Pirenzepine    Antagonist    Peptic ulcer disease        DAP000492    Approved
    P11229    M1 receptor    Glycopyrrolate    Antagonist    Anesthetic        DAP001116    Approved
    P11229    M1 receptor    Clidinium    Antagonist    Abdominal
    /stomach pain        DAP001117    Approved
    P11229    M1 receptor    Dicyclomine    Antagonist    Irritable bowel syndrome        DAP001118    Approved
    P11229    M1 receptor    Ethopropazine    Antagonist    Parkinson
    's disease        DAP001119    Approved
    P11229    M1 receptor    Cycrimine    Binder    Parkinson'
    s disease        DAP001120    Approved
    P11229    M1 receptor    Benztropine    Antagonist    Parkinson
    's disease        DAP001121    Approved
    P11229    M1 receptor    Trihexyphenidyl    Antagonist    Parkinson'
    s disease        DAP001122    Approved
    P11229    M1 receptor    Propantheline    Antagonist    Excessive sweating 
    (hyperhidrosis)        DAP001123    Approved
    P11229    M1 receptor    Oxyphenonium    Antagonist    Spasm        DAP001124    Approved
    P11229    M1 receptor    Biperiden    Antagonist    Parkinson
    's disease        DAP001125    Approved 
    Attached Files
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    782
    Rep Power
    495
    This looks to me as a duplicate of your previous post.

    And you don't explain what you want. Please do explain it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    63
    Rep Power
    2
    Hi

    Thanks for reply. I need to fetch words like agnostic antagonist binder inhibitior in front of the name of drug as mentioned in my ouput above on columns. Above mentioned output are expected output for which I have attached files as well

    My current code does not give me these words as mentioned in the input vefore drug name.

    Kindly check it
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    782
    Rep Power
    495
    Well, there is quite a bit in your files and in you code, and it is quite late over here by now, I don't feel like trying to do it now. I will try to take a look tomorrow.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    63
    Rep Power
    2
    No problem!just let me knoq qhwn you aee able to get.Mani

IMN logo majestic logo threadwatch logo seochat tools logo