Based on your sample I think this works. My assumption was that any row with pipe separated elements in the thrid field would have UniProt as the next to last in the series. If not, use a[n-1] if you want to capture that data, or add an if to test if a[n-1] is UniProt.
Code:
awk -F "\t" '
{
n = split( $3, a, "|" );
if( n < 2 )
data = sprintf( "%s\t", a[1] );
else
data = sprintf( "%s\t%s", "UniProt", a[n] ); #assumption that all pipe separated data contains UniProt at a[n-1]
printf( "%s\t%s\t%s\t%s\n", $1, $2, data, $4 );
}
' input-file >output-file
Last edited by agama; 04-17-2012 at 10:02 PM..
Reason: typo
Hi all,
I have a field in the line, let's say argument $6, which is in the format 00.00
If i want to split the field to get rid of the "." in between of the amount, how can i do that i awk script?
I have it like this
split($6,a,".")
but it will get rid of the last 2 digits after the... (4 Replies)
I am trying to pull data out of a file to execute a series of repetitive commands. One of the fields is a {hex number}.{hex number} pattern. I need the first part of that structure to pass into the command. The file structure is like this:
A 2007/10/20 09:50:00 li text ef6da.1 name ... (6 Replies)
Hi,
I have a comma delimited text file where character fields (as opposed to numeric and date fields) are always enclosed with double quotes. Records are separated by the newline character. In a shell script I would like to split a particular field into two separate fields (enclosed with double... (4 Replies)
Hi there I have a text file with several fields separated by ";" as follow :
5466-43;5466;JOAN;LIGA;LIGA ESPANOLA;43;DEP LA CORUNA - OSASUNA;10/01/10 17:00
5466-44;5466;CARLES;LIGA;LIGA ESPANOLA;44;MALAGA - ATHL BILBAO;10/01/10 17:00
5466-45;5466;FAB;LIGA;LIGA ESPANOLA;45;REAL MADRID -... (4 Replies)
Hi all,
I have a .vcf file which contains 8 coulmns and the data under each column as shown below,
CHROM POS ID REF ALT QUAL FILTER INFO
1 3000012 . A G 126 ... (6 Replies)
I want to use awk to split fields and put them into a file
but I don't know the number of fields
for example, in the following line
Ports: 22/filtered/tcp//ssh///, 53/open/tcp//tcpwrapped///, 111/filtered/tcp//rpcbind///, 543/filtered/tcp//klogin///, 544/filtered/tcp//kshell///,... (3 Replies)
Hi experts,
I need to print the first field first then last two fields should come next and then i need to print rest of the fields.
Input :
a1,abc,jsd,fhf,fkk,b1,b2
a2,acb,dfg,ghj,b3,c4
a3,djf,wdjg,fkg,dff,ggk,d4,d5
Expected output:
a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
I am trying to split a tab-delimeted file using awk after the second _ in bold. The awk below is close but splits on the first _, and I am not sure how to use the second _. Thank you :).
file
chr1 92145889 92149424 NM_001195684_exon_0_10_chr1_92145900_r 0 -
chr1 92161218 ... (4 Replies)
In the tab-delimited input below I am trying to use awk to -10 from $2 and +10 to $3. Something like
awk -F'\t' -v OFS='\t' -v s=10 '{split($4,a,":"); print $1,$2-s,$3+s,a,$5,$6} | awk {split(a,b,"-"); print $1,$2-s,$3+s,b-s,b+s,$5,$6}' input
should do that. I also need to -10 from $4... (2 Replies)
In the awk I am splitting on the : into array a, then splitting on the - into element b. I can not seem to duplicate b if there is no - after it. Lines 1,2,4 are examples. If there is a - after the number in b then the value to the right of it is $3 in the ouput. Thank you :).
awk... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT DEBIAN
go::metadata::panther
GO::Metadata::Panther(3pm) User Contributed Perl Documentation GO::Metadata::Panther(3pm)NAME
GO::Metadata::Panther - Species info for data used by Panther Clusters
SYNOPSIS
use GO::Metadata::Panther qw/@species/;
for my $species (@species) {
# do something
}
Or
use GO::Metadata::Panther;
my $s = GO::Metadata::Panther->code('YEAST');
DESCRIPTION
Accesses information related to species in the Panther seq2pthr.gz file. This file can be fetched from:
<ftp://ftp.pantherdb.org/genome/pthr7.0/>
Each item in the exportable @species array contains a hash reference for each species. The items in that hash are:
code
A scalar or the UniProt species code.
ncbi_taxa_id
A scalar reference of NCBI taxa ids that items in the GO database match. This should only be one id, but sometimes it's useful to scan
multiple.
For a complete list of every UniProt species matched to a NCBI taxa <http://www.uniprot.org/docs/speclist>
Constructors
The constructors scans @species for the requested data and returns the object that matches the data. Otherwise it returns a false false.
my $s = GO::Metadata::Panther->code(unicode_species_code)
Return an object filled with the species reference from the UniProtKB species code.
my $s = GO::Metadata::Panther->ncbi(ncbi_taxa_id)
Greate an object from the ncbi_taxa_id.
Function
Functions that can be used outside of the OO interface.
GO::Metadata::Panther::codes()
Returns a list of all UniProt species codes in @species.
GO::Metadata::Panther::valid_codes(unicode_species_code)
Send it a list of panther Unicode codes, returns true if they are all present in @species. Othewise returns false.
OO Function
$s->ncbi_ids()
Returns the list of NCBI taxa identifiers associated with the UniProt species code. In a perfect word this will only every return one
value. In any case, the first value will be the actual numeric identifier associated.
AUTHOR
Sven Heinicke <sven@genomics.princeton.edu</gt>
perl v5.14.2 2010-07-08 GO::Metadata::Panther(3pm)