Search Results

Search: Posts Made By: pawannoel
1,300
Posted By Scrutinizer
awk -F'/|"' '$3~"m|M"{printf "%.1f\n",...
awk -F'/|"' '$3~"m|M"{printf "%.1f\n", $2/12;next} {print $2+0}' infile
1,300
Posted By bartus11
AWK:awk -F"/" '{gsub("\"","")}$2~"a|A"{printf...
AWK:awk -F"/" '{gsub("\"","")}$2~"a|A"{printf ("%d\n",$1)}$2~"m|M"{printf ("%.1f\n",$1/12)}' file
1,300
Posted By balajesuri
perl -lne 'if(/(\d+)[...
perl -lne 'if(/(\d+)[ ]?\/a/i){$x=$1;$x=~s/^0*//;print"$x"}
if(/(\d+)[ ]?\/m/i){$y=$1;$y=~s/^0*//;printf "%0.1f\n",$y/12}' inputfile
3,834
Posted By bartus11
I think the best way to do it is to use hash of...
I think the best way to do it is to use hash of array references, instead of arrays. Try this code: #!/usr/bin/perl
@arrchr = qw(chr02 chr02 chr02 chr02 chr02 chr03 chr03 chr04 chr04 chr05 chr05...
3,834
Posted By bartus11
Try: @array = map...
Try: @array = map {$x=($x{$_})?"_":$_;$x{$_}=1;($x)} @array;
1,553
Posted By bartus11
#!/usr/bin/perl print "Enter minimum coverage:...
#!/usr/bin/perl
print "Enter minimum coverage: ";
chomp($min_cov=<STDIN>);
print "Enter minimum novel_Allele_Starts: ";
chomp($min_nas=<STDIN>);
open I, "$ARGV[0]";
while (<I>){
@F=split;
...
1,553
Posted By bartus11
"cmp" is a similar operator to "<=>", just...
"cmp" is a similar operator to "<=>", just designed to compare strings ;)
1,553
Posted By bartus11
Try: @sorted=sort {$a cmp $b} keys %h; for $i...
Try: @sorted=sort {$a cmp $b} keys %h;
for $i (@sorted){
print "$i\t$h{$i}\n";
}
19,588
Posted By bartus11
Try: #!/usr/bin/perl print "Enter minimum...
Try: #!/usr/bin/perl
print "Enter minimum coverage: ";
chomp($min_cov=<STDIN>);
open I, "$ARGV[0]";
while (<I>){
$pos=((split "[\t ]+",$_)[4]);
$cov=((split "=",(split ";",(split "[\t...
1,522
Posted By pludi
In an opened terminal window or on the console...
In an opened terminal window or on the console enter export PATH=$PATH:/Volumes/USB/Perl_course/Recent/Scripts. Note that this sets the search path only for the current window (not others), and only...
1,362
Posted By bartus11
The "1" at the end of AWK command is the same as...
The "1" at the end of AWK command is the same as putting "print" statement there. Perl version of that code:perl -anle '$F[1]+=0.1 if $.>5 && $.<9;print join " ",@F' fileOutput is a bit messed up...
1,982
Posted By bartus11
$& holds string that was matched by last regex,...
$& holds string that was matched by last regex, so in s/.{100}/$&\n/g; it will contain hundred characters, to which newline is then appended. It is done to restore your formating of hundred chars per...
1,982
Posted By bartus11
map function is used to create hash from the...
map function is used to create hash from the contents of @b array (which contains lines from postion_file). When map is executed, its code is run for each element of the @b array. When processing...
1,982
Posted By bartus11
Weird... It is working for...
Weird... It is working for me:oracle@solaris:~/unix/dna$ cat file
>S5_SK1.chr01
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...
1,982
Posted By bartus11
Try: #!/usr/bin/perl open I,"position_file"; ...
Try: #!/usr/bin/perl
open I,"position_file";
@b=<I>;
%h=map {((split /\s+/)[1],(split /\s+/)[2]);} @b;
local $/;
open J,"main_file";
$_=<J>;
s/(>.*)//;
$n=$1;
s/\n//g;
@F=split //,$_;
for...
1,479
Posted By ctsgnb
nawk '{| call nawk x=$1|store 1rst field in...
nawk '{| call nawk
x=$1|store 1rst field in variable x
sub(".*[.]","",x)|replace the string followed by the dot by nothing (extract only the chr<nn> part) into the x variable
A[$2]=x|create...
1,479
Posted By bartus11
Perl solution:perl -alne '$F[0]=~s/.*\.//;push...
Perl solution:perl -alne '$F[0]=~s/.*\.//;push @{$a{$F[1]}},$F[3];push @{$b{$F[1]}},$F[4];$c{$F[1]}=$F[0];END{for $i (keys %a){print "$c{$i}\t$i\t",@{$a{$i}},"\t",@{$b{$i}}}}' file
1,479
Posted By ctsgnb
nawk...
nawk '{x=$1;sub(".*[.]","",x);A[$2]=x;B[$2]=B[$2]$4""}END{for(i in A) print A[i],i,B[i]}' inputfile

Ooops, i missed the $5 here you go :

nawk...
1,813
Posted By bartus11
Just one small thing.. s/// is not "sed" :) it is...
Just one small thing.. s/// is not "sed" :) it is "substitute operator", that is present in many tools (sed, vi, Perl).
1,813
Posted By bartus11
Try: #!/usr/bin/perl open I, "$ARGV[0]"; ...
Try: #!/usr/bin/perl
open I, "$ARGV[0]";
local $/;
$_=<I>;
s/^(>.*)\n//;
print "$1\n";
s/\n//g;
$a=1;
while (/N+|[ACGT]+/g){
$s=$&;
$l=length $s;
@F=split //, $s;
for $i (@F){
...
8,914
Posted By bartus11
for i in S5_*; do perl -i -pe 's/.*/>$ARGV/ if...
for i in S5_*; do
perl -i -pe 's/.*/>$ARGV/ if $.==1' $i
done
8,914
Posted By bartus11
If you have few files starting with "S5_" in your...
If you have few files starting with "S5_" in your current directory, and you run this code just once: perl -i -pe 's/.*/>$ARGV/ if $.==1' S5_*, then it will automatically change contents of all the...
8,914
Posted By bartus11
Try: perl -i -pe 's/.*/>$ARGV/ if $.==1' S5_*
Try: perl -i -pe 's/.*/>$ARGV/ if $.==1' S5_*
8,914
Posted By tene
awk '{if( NR==1)print ">"FILENAME;else print}'...
awk '{if( NR==1)print ">"FILENAME;else print}' S5_SK1.chr01
1,754
Posted By ctsgnb
you can add [[ -z $a ]] && continue just...
you can add
[[ -z $a ]] && continue
just after the "do" line so that empty lines will not be a problem
Showing results 1 to 25 of 119

 
All times are GMT -4. The time now is 03:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy