![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| XML file modifications using sed | potro | Shell Programming and Scripting | 2 | 05-27-2009 10:46 AM |
| how to write modifications in to two tables | naveeng.81 | Shell Programming and Scripting | 0 | 04-09-2008 01:26 PM |
| my shell script (file modifications) | whizkidash | Shell Programming and Scripting | 2 | 03-24-2008 03:50 PM |
| Tracing file modifications | gupta_ca | UNIX for Advanced & Expert Users | 3 | 08-03-2005 08:50 AM |
| In Line File Modifications: Search and Replace | Shakey21 | Shell Programming and Scripting | 2 | 11-20-2001 04:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Modifications to a file
Hi,
I do not have a clue how to do this nor can I find information on it but I have a file that looks like this (basically 3 columns and tab delimited). I need this in a particular format in order for a program to actually read it. Code:
chr1 2 4 chr1 2 5 chr1 3 6 chr2 1 4 chr2 2 5 Code:
track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on variableStep chrom=chr1 span=1 2 4 2 5 3 6 track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on variableStep chrom=chr2 span=1 1 4 2 5 thanks |
|
||||
|
This might do it?
Code:
awk 'p!=$1{p=$1;printf "track type=wiggle_0 name=\"Name\" description=\"Name\" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on\nvariableStep chrom="$1" span=1\n"}{print $2"\t"$3}' infile
|
|
||||
|
Code:
my $name;
my $header='track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on variableStep chrom=<NAME> span=1';
while(<DATA>){
chomp;
my @tmp=split;
if($name eq "" || $name ne $tmp[0]){
$name=$tmp[0];
(my $tmp_header=$header)=~s/<NAME>/$name/;
print $tmp_header,"\n";
}
print "@tmp[1..$#tmp]\n";
}
__DATA__
chr1 2 4
chr1 2 5
chr1 3 6
chr2 1 4
chr2 2 5
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|