Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2012, 04:00 AM
manigrover manigrover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 manigrover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 42 m 3 sec
Reputation 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    MNTSAPPAVSPNITVLAPGKGPWQVAFIGITTGLLSLATVTGNLLVLISFKVNTELKTVNNYFLLSLACADLIIGTFSMNLYTTYLLMGHWALGTLACDL  WLALDYVASNASVMNLLLISFDRYFSVTRPLSYRAKRTPRRAALMIGLAWLVSFVLWAPAILFWQYLVGERTVLAGQCYIQFLSQPIITFGTAMAAFYLP  VTVMCTLYWRIYRETENRARELAALQGSETPGKGGGSSSSSERSQPGAEGSPETPPGRCCRCCRAPRLLQAYSWKEEEEEDEGSMESLTSSEGEEPGSEV  VIKMPMVDPEAQAPTKQPPRSSPNTVKRPTKKGRDRAGKGQKPRGKEQLAKRKTFSLVKEKKAARTLSAILLAFILTWTPYNIMVLVSTFCKDCVPETLW  ELGYWLCYVNSTINPMCYALCNKAFRDTFRLLLLCRWDKRRWRKIPKRPGSVHRTPSRQC
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
File Type: txt sample input file TTD.txt (2.6 KB, 29 views)
File Type: txt expected sample output .txt (916 Bytes, 38 views)

Reply With Quote
  #2  
Old November 30th, 2012, 12:49 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 502 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 18 h 51 m 13 sec
Reputation Power: 385
This looks to me as a duplicate of your previous post.

And you don't explain what you want. Please do explain it.

Reply With Quote
  #3  
Old November 30th, 2012, 03:30 PM
manigrover manigrover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 manigrover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 42 m 3 sec
Reputation 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

Reply With Quote
  #4  
Old November 30th, 2012, 04:28 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 502 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 18 h 51 m 13 sec
Reputation Power: 385
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.

Reply With Quote
  #5  
Old December 2nd, 2012, 06:13 AM
manigrover manigrover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 60 manigrover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 42 m 3 sec
Reputation Power: 2
No problem!just let me knoq qhwn you aee able to get.Mani

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Request to provide changes in code according to output

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap