Request to check:Fetch certain entries


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Request to check:Fetch certain entries
# 1  
Old 07-19-2012
Request to check:Fetch certain entries

Hi all.

Kindly check it it's urgent!!

I have one big file from which which I have to fetch certain data

I have attached a small part of this file.

from the attached file, I have to fetch and arrange data in 3 columns

1 Generic name 2. Brand names 3. Drug Target_gene name

In the attached file this data is arranged like this along with so much other data mixed in between
Quote:
Drug Card I

Generic name

Brand names

Drug_Target_ gene name

End Drug card I


Begin Drug card II

Generic name

Brand names

Drug_Target_gene name
Drug_Target_gene name
Drug_Target_gene name
Drug_Target_gene name...so on
End Drug card II....

in this way there are many drug cards.


Please check the attached file and Kindly let me know scripting to perform this task.

I want the output shuld be like this:

Quote:
Generic name Brand names Drug Target_gene name

Lepirudin Refludan F2

Last edited by manigrover; 07-20-2012 at 12:46 AM..
# 2  
Old 07-19-2012
attached file

Hi all

Please check attached file. sorry I forgot to attach previously.

Mani
# 3  
Old 07-20-2012
Urgent for me:Kindly check: fetching entries

Quote:
Originally Posted by manigrover
Hi all.

Kindly check it it's urgent!!

I have one big file from which which I have to fetch certain data

I have attached a small part of this file.

from the attached file, I have to fetch and arrange data in 3 columns

1 Generic name 2. Brand names 3. Drug Target_gene name

In the attached file this data is arranged like this along with so much other data mixed in between

End Drug card II....

in this way there are many drug cards.


Please check the attached file and Kindly let me know scripting to perform this task.

I want the output shuld be like this:
# 4  
Old 07-21-2012
Please check this one:fetch entries.

Quote:
Originally Posted by manigrover
Hi all.

Kindly check it it's urgent!!

I have one big file from which which I have to fetch certain data

I have attached a small part of this file.

from the attached file, I have to fetch and arrange data in 3 columns

1 Generic name 2. Brand names 3. Drug Target_gene name

In the attached file this data is arranged like this along with so much other data mixed in between

End Drug card II....

in this way there are many drug cards.


Please check the attached file and Kindly let me know scripting to perform this task.

I want the output shuld be like this:
# 5  
Old 07-21-2012
Hi,

Try this

Code:
awk 'k>0 {if (a[k] && k==2) {print a[1]" "a[2]" "a[3]; a[1]=a[2]=a[3]="";} a[k]=a[k]?a[k]" "$0:$0; k=0;} /^# Drug_Target_.*_Gene_Name/ {k=3;} /^# Generic/ {k=1;} /^# Brand_Name/ {k=2;} END {if (a[1]) print a[1]" "a[2]" "a[3];}' drug_bank.dat

# 6  
Old 07-22-2012
Request to check

Hi CHirel

Thankyou very much It was very helpful

On the same lines I posted one more question

Extract certain entries from big file:Request to check Hi all


I have a big file which I have attached here.

And, I have to fetch certain entries and arrange in 5 columns


Code:
Name Drug DAP ID disease approved or not

In the attached file data is arranged with tab separated columns in this way:
Quote:
TTDS00001 Name

Drug(s) DAPID Disease name Approved /(blank)


and other data is also present which I dont want to fetch

I want the output should be like this


Quote:
Name Drug DAP ID disease Approved or not

Muscarinic Bethanechol DAP000263 Urinary retention Approved
acetylcholine
receptor
Can u please check once. Highly thankful toyou.

---------- Post updated at 12:00 PM ---------- Previous update was at 01:46 AM ----------

Hi

I found one issue from previous answer because I have to separate into three different columns and its not showing in three columns as there is space beteeen gene names as well as within generic and brand ame then I m trying to make 2 different files with generic and brand names

can we separate brand name and generic name?

means
For only generic name using

Quote:
awk 'k>0 {if (a[k] && k==2) {print a[1]" "a[2]" "a[3]; a[1]=a[2]=a[3]="";} a[k]=a[k]?a[k]" "$0:$0; k=0;} /^# Drug_Target_.*_Gene_Name/ {k=3;} /^# Generic/ {k=1;} END {if (a[1]) print a[1]" "a[2]" "a[3];}' drug_bank.dat

For only brand name

Quote:
awk 'k>0 {if (a[k] && k==2) {print a[1]" "a[2]" "a[3]; a[1]=a[2]=a[3]="";} a[k]=a[k]?a[k]" "$0:$0; k=0;} /^# Drug_Target_.*_Gene_Name/ {k=3;} /^# Brand_Name/ {k=2;} END {if (a[1]) print a[1]" "a[2]" "a[3];}' drug_bank.dat

Last edited by manigrover; 07-22-2012 at 02:08 PM..
# 7  
Old 07-22-2012
Hi

I'm not sure i really understand what you want, but i guess that if you replace in my code,
print a[1]" "a[2]" "a[3] by print a[1]":"a[2]":"a[3], then you will have an output with always 3 fields separated by ":".

This way you can process them is any way you want, being sure that field 1 is always generic & field 2 is always brand name.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Urgent request to consider:Search specific name in a file and fetch specific entries

Hi all, I have 2 files, One file contain data like this FHIT CS CHRM1 PDE3A PDE3B HSP90AA1 PTK2 HTR1A ESR1 PARP1 PLA2G1B These names are mentioned in the second file(Please see attached second file) as # Drug_Target_X_Gene_Name:(Where X can be any number (1-1000) (1 Reply)
Discussion started by: manigrover
1 Replies

2. Shell Programming and Scripting

Extract certain entries from big file:Request to check

Hi all I have a big file which I have attached here. And, I have to fetch certain entries and arrange in 5 columns Name Drug DAP ID disease approved or notIn the attached file data is arranged with tab separated columns in this way: and other data is... (2 Replies)
Discussion started by: manigrover
2 Replies

3. Shell Programming and Scripting

Request to check:count specific entries

Hi all I have an input file which contains so many entries like this: And, I want to count hw many among ASN in one column are converted to LYS in third coulmns. which means output shuld contain only "ASN number LYS" Kindly let me know wny programm for this My input is ASN 217 LYS... (2 Replies)
Discussion started by: manigrover
2 Replies

4. Shell Programming and Scripting

Request to check: Not printing all entries

Dear all, I am facing one problem in my input file there are many Entries which starts from *FIELD * AV (checked the attached file) I want all the entries in the output file which start from *FIELD * AV I have written this programm but its not printing all the entries with *FIELD... (4 Replies)
Discussion started by: manigrover
4 Replies

5. Shell Programming and Scripting

Request to check:remove entries more than once in different column

Hi I have a file 12m 345693460 12 1234 12 1234 34 345 34 345 And I want output fiel as 12m 345693460 12 1234 34 345 hw can it be done Thanks (1 Reply)
Discussion started by: manigrover
1 Replies

6. Shell Programming and Scripting

Request to check:remove entries with N/A mentioned

Hi I have a file with following entries 122 N/A 123 5654656 123423 43534543 4544 45435 435454 N/A i Have to remove entries with N/A so that only 123 5654656 123423 43534543 4544 45435 remain in output file can anybody guide for a code/unix/perl (2 Replies)
Discussion started by: manigrover
2 Replies

7. Shell Programming and Scripting

Request to check:remove entries with blank spaces

Hi I want to remove entries with blank spaces in my input file: 123 234 456 678 56789 345346456 589 3454 345456 3454566............................ (2 Replies)
Discussion started by: manigrover
2 Replies

8. Shell Programming and Scripting

Request to check:remove entries more than once

Hi I have a file like this 1234 2345 567889 567889 2345 234899420 83743 2345 67890 67890 ................ so on I want to delete entries which are more than once like 2345, 567889 and 67890 so that these appear once (4 Replies)
Discussion started by: manigrover
4 Replies

9. Shell Programming and Scripting

Request to check:remove entries with N/A entries

Hi I have a file with numerous entries some entries are 1 mani 2 kavya 3 N/A 4 Praveeen 5 N/A and so on How to remove entries with N/A so the result will be 1 mani 2 kavya 3 Praveeen (6 Replies)
Discussion started by: manigrover
6 Replies

10. Shell Programming and Scripting

Request to check:find out common entries

I have to compare 2 files which means 2 files with common entries in same column and separate those common entries in a diferent file as well right before those entries common so that I can separat common and Uncommon entries in rows in 2 different files. Is it possible For eg. one file ... (3 Replies)
Discussion started by: manigrover
3 Replies
Login or Register to Ask a Question