The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Changes in perl code to fetch more data
Discuss Changes in perl code to fetch more data in the Perl Programming forum on Dev Shed. Changes in perl code to fetch more data Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 27th, 2012, 04:44 PM
|
|
Contributing User
|
|
Join Date: May 2012
Posts: 60
Time spent in forums: 10 h 42 m 3 sec
Reputation Power: 2
|
|
|
Changes in perl code to fetch more data
My sample part of input file is
PHP Code:
TTDS00001 Name Muscarinic acetylcholine receptor
TTDS00001 Type of target Successful target
TTDS00001 Synonyms (m)AChR
TTDS00001 Synonyms MAChR
TTDS00001 Disease Alzheimer's disease
TTDS00001 Disease Bronchospasm (histamine induced)
TTDS00001 Disease Glaucoma
TTDS00001 Disease Motion sickness
TTDS00001 Disease Obstructive airway disease
TTDS00001 Disease Organophosphate poisoning
TTDS00001 Disease Schizophrenia
TTDS00001 Disease Urinary incontinence
TTDS00001 Disease Xerostomia
TTDS00001 BioChemical Class G-protein coupled receptor (rhodopsin family)
TTDS00001 Pathway Calcium signaling pathway
TTDS00001 Pathway Neuroactive ligand-receptor interaction
TTDS00001 Pathway Regulation of actin cytoskeleton
TTDS00001 Related US Patent 6,211,204
TTDS00001 Related US Patent 6,323,194
TTDS00001 Related US Patent 6,369,081
TTDS00001 Related US Patent 6,376,675
TTDS00001 Related US Patent 6,423,842
TTDS00001 Related US Patent 6,451,797
TTDS00001 Related US Patent 6,455,552
TTDS00001 Related US Patent 6,458,812
TTDS00001 Related US Patent 6,555,550
TTDS00001 Related US Patent 6,602,891
TTDS00001 Drug(s) Bethanechol DAP000263 Urinary retention Approved
TTDS00001 Drug(s) Trospium DAP000342 Spasm Approved
TTDS00001 Drug(s) Oxyphencyclimine DAP000835 Gastrointestinal disorders Approved
TTDS00001 Drug(s) Tridihexethyl DAP000836 Acquired nystagmus Approved
TTDS00001 Drug(s) Anisotropine Methylbromide DAP000837 Peptic ulcer disease Approved
TTDS00001 Drug(s) Hyoscyamine DAP001108 Gastrointestinal disorders Approved
TTDS00001 Drug(s) Methantheline DAP001109 Irritable bowel syndrome Approved
TTDS00001 Drug(s) Procyclidine DAP001110 Parkinson's disease Approved
TTDS00001 Drug(s) Cyclopentolate DAP001111 Pediatric eye examinations Approved
TTDS00001 Drug(s) Ipratropium DAP001112 Obstructive lung diseases Approved
TTDS00001 Drug(s) Pilocarpine DAP001113 Glaucoma Approved
TTDS00001 Drug(s) Flavoxate DAP001114 Muscle Relaxant Approved
TTDS00001 Drug(s) Mepenzolate DAP001115 Peptic ulcer disease Approved
TTDS00001 Drug(s) Ispaghula DAP001486 Irritable bowel syndrome Approved
TTDS00001 Drug(s) Mebeverine DAP001494 Irritable bowel syndrome Approved
TTDS00001 Drug(s) Trihexyphenidyl HCl DAP001532 Parkinson's Disease Approved
TTDS00001 Antagonist Trospium DAP000342
TTDS00001 Antagonist Hyoscyamine DAP001108
TTDS00001 Antagonist Methantheline DAP001109
TTDS00001 Antagonist Procyclidine DAP001110
TTDS00001 Antagonist Cyclopentolate DAP001111
TTDS00001 Antagonist Ipratropium DAP001112
TTDS00001 Antagonist Flavoxate DAP001114
TTDS00001 Antagonist Mepenzolate DAP001115
TTDS00001 Antagonist Ispaghula DAP001486
TTDS00001 Antagonist Mebeverine DAP001494
TTDS00001 Antagonist Trihexyphenidyl HCl DAP001532
TTDS00001 Agonist Bethanechol DAP000263
TTDS00001 Agonist Pilocarpine DAP001113
TTDS00001 Binder Oxyphencyclimine DAP000835
TTDS00001 Binder Tridihexethyl DAP000836
TTDS00001 Binder Anisotropine Methylbromide DAP000837
TTDS00001 Drug(s) Aclidinium bromide DCL000677 Chronic obstructive pulmonary disease Phase III
TTDS00001 Drug(s) CHF 5407 DCL000750 Chronic obstructive pulmonary disease Phase I
TTDS00001 Drug(s) GSK233705 DCL000823 Chronic obstructive pulmonary disease Phase II completed
TTDS00001 Drug(s) NVA237 DCL000901 Chronic obstructive pulmonary disease Phase III
TTDS00001 Drug(s) Org-23366 DCL000911 Schizophrenia No development reported
TTDS00001 Drug(s) OrM3 DCL000913 Chronic obstructive pulmonary disease Phase IIb
TTDS00001 Antagonist Aclidinium bromide DCL000677
TTDS00001 Antagonist CHF 5407 DCL000750
TTDS00001 Antagonist GSK233705 DCL000823
TTDS00001 Antagonist NVA237 DCL000901
TTDS00001 Antagonist Org-23366 DCL000911
TTDS00001 Antagonist OrM3 DCL000913
TTDS00001 Multitarget Org-23366 DCL000911
TTDS00001 Antagonist Aprophen DNC000245
TTDS00001 Antagonist Benactyzine DNC000293
TTDS00001 Antagonist Hyoscine DNC000757
TTDS00001 Antagonist Hyoscyamine sulfate DNC000758
TTDS00001 Antagonist Ipratropium bromide DNC000806
TTDS00001 Agonist Muscarine DNC000970
TTDS00001 Agonist RS 86 DNC001236
TTDS00001 Target Validation TTDS00001
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
TTDS00002 Drug(s) Talsaclidine isomer DCL000268 Alzheimer's disease Discontinued
TTDS00002 Drug(s) Sabcomeline hydrochloride DCL000279 Cardiovascular diseases Phase IIa
TTDS00002 Drug(s) Talsaclidine fumarate DCL000303 Alzheimer's disease Discontinued
TTDS00002 Drug(s) Xanomeline tartrate DCL000328 Alzheimer's disease Phase II
TTDS00002 Drug(s) GSK573719 DCL000381 Chronic Obstructive Pulmonary Disease (COPD) Phase II
TTDS00002 Drug(s) GSK961081 DCL000397 Chronic Obstructive Pulmonary Disease (COPD) Phase II completed
TTDS00002 Drug(s) GSK1034702 DCL000402 Schizophrenia, Dementia Phase I completed
TTDS00002 Drug(s) Darotropium DCL000514 COPD Suspended in Phase II in GSK 2009 Report
TTDS00002 Drug(s) Darotropium + 642444 DCL000515 COPD Phase III
TTDS00002 Drug(s) Revatropate DCL000957 Chronic obstructive pulmonary disease Discontinued in Phase I
TTDS00002 Antagonist Revatropate DCL000957
TTDS00002 Agonist Talsaclidine isomer DCL000268
TTDS00002 Agonist Sabcomeline hydrochloride DCL000279
TTDS00002 Agonist Talsaclidine fumarate DCL000303
TTDS00002 Agonist Xanomeline tartrate DCL000328
TTDS00002 Agonist GSK573719 DCL000381
TTDS00002 Agonist GSK961081 DCL000397
TTDS00002 Agonist GSK1034702 DCL000402
TTDS00002 Agonist Darotropium DCL000514
TTDS00002 Agonist Darotropium + 642444 DCL000515
TTDS00002 Multitarget GSK961081 DCL000397
TTDS00002 Multitarget Revatropate DCL000957
TTDS00002 Agonist 77-LH-28-1 DNC000099
TTDS00002 Agonist AC-260584 DNC000137
TTDS00002 Agonist AC-42 DNC000138
TTDS00002 Agonist AF150(S) DNC000165
TTDS00002 Agonist AF267B DNC000166
TTDS00002 Agonist LY-593039 DNC000910
TTDS00002 Agonist NGX-267 DNC001012
TTDS00002 Agonist Sabcomeline DNC001264
TTDS00002 Agonist WAY-132983 DNC001510
TTDS00002 Inhibitor Arecoline DNC002508
TTDS00002 Inhibitor Acetic acid 8-aza-bicyclo[3.2.1]oct-6-yl ester DNC003640
TTDS00002 Inhibitor Benzoic acid 8-aza-bicyclo[3.2.1]oct-6-yl ester DNC003654
TTDS00002 Inhibitor Propionic acid 8-aza-bicyclo[3.2.1]oct-6-yl ester DNC003659
TTDS00002 Inhibitor 3-Methyl-7-pyrrolidin-1-yl-hept-5-yn-2-one DNC004147
TTDS00002 Inhibitor 2-Methyl-6-pyrrolidin-1-yl-hex-4-ynal oxime DNC004159
My code is
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;
}
My output contain following
data but I want to add data like agnostic, binder and other stuff mentioned before name of drug in separat ecolumn
PHP Code:
CHRM1 P11229 Pirenzepine DAP000492 Peptic ulcer disease Approved T2D
CHRM1 P11229 Glycopyrrolate DAP001116 Anesthetic Approved T2D
CHRM1 P11229 Clidinium DAP001117 Abdominal/stomach pain Approved T2D
CHRM1 P11229 Dicyclomine DAP001118 Irritable bowel syndrome Approved T2D
CHRM1 P11229 Ethopropazine DAP001119 Parkinson's disease Approved T2D
CHRM1 P11229 Cycrimine DAP001120 Parkinson's disease Approved T2D
CHRM1 P11229 Benztropine DAP001121 Parkinson's disease Approved T2D
CHRM1 P11229 Trihexyphenidyl DAP001122 Parkinson's disease Approved T2D
CHRM1 P11229 Propantheline DAP001123 Excessive sweating (hyperhidrosis) Approved T2D
CHRM1 P11229 Oxyphenonium DAP001124 Spasm Approved T2D
CHRM1 P11229 Biperiden DAP001125 Parkinson's disease Approved T2D
CHRM1 P11229 Talsaclidine isomer DCL000268 Alzheimer's disease Discontinued T2D
CHRM1 P11229 Sabcomeline hydrochloride DCL000279 Cardiovascular diseases Phase IIa T2D
CHRM1 P11229 Talsaclidine fumarate DCL000303 Alzheimer's disease Discontinued T2D
CHRM1 P11229 Xanomeline tartrate DCL000328 Alzheimer's disease Phase II T2D
CHRM1 P11229 GSK573719 DCL000381 Chronic Obstructive Pulmonary Disease (COPD) Phase II T2D
CHRM1 P11229 GSK961081 DCL000397 Chronic Obstructive Pulmonary Disease (COPD) Phase II completed T2D
CHRM1 P11229 GSK1034702 DCL000402 Schizophrenia, Dementia Phase I completed T2D
CHRM1 P11229 Darotropium DCL000514 COPD Suspended in Phase II in GSK 2009 Report T2D
CHRM1 P11229 Darotropium + 642444 DCL000515 COPD Phase III T2D
CHRM1 P11229 Revatropate DCL000957 Chronic obstructive pulmonary disease Discontinued in Phase I T2D
FLT1 P17948 Sorafenib DAP000006 Advanced renal cell carcinoma Launched CAD
FLT1 P17948 Sorafenib DAP000006 Hepatocellular carcinoma, NSCLC, melanoma Phase III CAD
FLT1 P17948 Sorafenib DAP000006 Myelodyspalstic syndrome, AML, head & neck cancer, breast, colon, ovarian, pancreatic cancer Phase II CAD
FLT1 P17948 Ranibizumab DAP001260 Age-related macular degeneration Approved CAD
FLT1 P17948 Ranibizumab DAP001260 Diabetic macular edema and retinal vein occlusion Phase III CAD
FLT1 P17948 Telbermin DCL001016 Diabetic foot ulcers Discontinued in Phase II CAD
KDR P35968 Sunitinib DAP000005 Advanced renal cell carcinoma Launched CAD,CD,CD
KDR P35968 Sunitinib DAP000005 Advanced renal cell carcinoma Phase II CAD,CD,CD
so expected output include one more column apart form above columns in which I want information regarding antagaonist, binder,agonist, multitarget. Please guide me.
Last edited by manigrover : November 27th, 2012 at 04:46 PM.
|

November 29th, 2012, 04:00 AM
|
|
Contributing User
|
|
Join Date: May 2012
Posts: 60
Time spent in forums: 10 h 42 m 3 sec
Reputation Power: 2
|
|
|
Request to check
I think I didnt mention my expected output separately therefore nobody replied
now I am mentioning the expected output here in which mechanism of action (agonist/antagonist/ inhibitor ) are mentioned in separated column
PHP Code:
CHRM1 P11229 Talsaclidine isomer DCL000268 Alzheimer's disease Discontinued Agonist
CHRM1 P11229 Sabcomeline hydrochloride DCL000279 Cardiovascular diseases Phase IIa Inhibior
CHRM1 P11229 Talsaclidine fumarate DCL000303 Alzheimer's disease Discontinued Activator
CHRM1 P11229 Xanomeline tartrate DCL000328 Alzheimer's disease Phase II Antagonist
|

November 29th, 2012, 07:16 PM
|
|
Contributing User
|
|
Join Date: May 2012
Posts: 60
Time spent in forums: 10 h 42 m 3 sec
Reputation Power: 2
|
|
|
Please let me know if somebody has suggestions to change the above code as I need it or if somebody didnt understand the questions kindly let me know
|

November 30th, 2012, 01:06 AM
|
|
|
|
Well, I did not understand exactly the details of what you want, but what really puzzles me is that if you were able to come up with the code you are presenting, you should really be able to make the apparently simple changes you need to do.
|

December 2nd, 2012, 04:51 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Quote: | Originally Posted by Laurent_R Well, I did not understand exactly the details of what you want, but what really puzzles me is that if you were able to come up with the code you are presenting, you should really be able to make the apparently simple changes you need to do. |
He didn't write that code. I did  .
http://forums.devshed.com/perl-prog...eck-922306.html
I don't think the OP really knows how to program in perl (or any other language for that matter). In case anyone wants to help, you can read the original post and figure out how this code is evolving.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

December 2nd, 2012, 10:41 PM
|
|
|
|
I've worked on several other of manigrover's questions and from what I see (s)he doesn't have any interest in learning Perl. (S)he simply want's someone else to do the coding/troubleshooting so that (s)he can get a good grade in the class.
|

December 3rd, 2012, 01:20 AM
|
|
|
Quote: | Originally Posted by Scorpions4ever He didn't write that code. I did  .
http://forums.devshed.com/perl-prog...eck-922306.html
I don't think the OP really knows how to program in perl (or any other language for that matter). In case anyone wants to help, you can read the original post and figure out how this code is evolving. |
OK, I did not remember that specific thread, and I was also a bit surprised as I did not have the impression so far that the OP was really trying to learn Perl.
|

December 9th, 2012, 07:31 PM
|
|
Contributing User
|
|
Join Date: May 2012
Posts: 60
Time spent in forums: 10 h 42 m 3 sec
Reputation Power: 2
|
|
|
Thanks for ur comments.
Well, I am a beginner to learn programming so slowly slowly I am able to write small code. But because its quite difficult for me to learn such complex things in a short period of time. Therefore, for quite complex problems like this I have to take forum help only!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|