Sponsored Content
Top Forums Shell Programming and Scripting sed variable expansion fails for substitution in range Post 302889786 by ahamed101 on Monday 24th of February 2014 12:54:04 AM
Old 02-24-2014
Like this?
Code:
AAA=G
sed "2,$ s/F/$AAA/g" infile

--ahamed

Last edited by ahamed101; 02-24-2014 at 02:03 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

2. Shell Programming and Scripting

SED variable substitution

Hi Chaps... I have a log file as below:- 01 Oct 2009 12:57:56 DEBUG : 01 Oct 2009 12:14:21 DEBUG :..... . . . .05 Oct 2009 14:31:56 DEBUG :.... . . .05 Oct 2009 12:57:56 DEBUG :.... 06 Oct 2009 01:23:11 DEBUG :.... . . .06 Oct 2009 12:53:46 DEBUG :.... (4 Replies)
Discussion started by: rpraharaj84
4 Replies

3. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

4. Shell Programming and Scripting

[Solved] Command Substitution and Variable Expansion within a Case

Hello All, I don't write scripts very often, and in this case I am stumped, although it may be a bug in the version of bash I have to use (it's not my system). I want to extract a specific string snippet from a block of text (coming from a log file) that is dependent on a bunch of other... (1 Reply)
Discussion started by: jaimielives
1 Replies

5. Shell Programming and Scripting

Sed variable substitution

Hello, I searched the forum and unable to find a solution for my particular problem. I have a text file I'm trying to insert some text using sed after finding a pattern.. File contains in one line Invoice date: xx/xx/xxxx Balance: $$$$ Name: xxxxxxxxxxxxxx Trying to insert Invoice "Number:... (3 Replies)
Discussion started by: mallu0987
3 Replies

6. Shell Programming and Scripting

Variable expansion in sed

The objective of the code below is to create sed script to be later executed. However, it bonks because $ARCHIVENAME expands to a directory specification so the forward slashes cause problems. I can think of a few solutions that would involve redesigning the process, but I'm hoping there might be... (4 Replies)
Discussion started by: tiggyboo
4 Replies

7. Shell Programming and Scripting

Sed - variable substitution

Problem with the code below is that the value of the variable is not getting substituted in the sed expression. #/bin/csh set UNIX_ID="rajibd" set X_ID="xrajibd" sed -n 's/$UNIX_ID/$X_ID/g' passwd When run , it is not giving expected output as shown below : ... (4 Replies)
Discussion started by: hiten.r.chauhan
4 Replies

8. Shell Programming and Scripting

sed filtering lines by range fails 1-line-ranges

The following is part of a larger project and sed is (right now) a given. I am working on a recursive Korn shell function to "peel off" XML tags from a larger text. Just for context i will show the complete function (not working right now) here: function pGetXML { typeset chTag="$1" typeset... (5 Replies)
Discussion started by: bakunin
5 Replies

9. Shell Programming and Scripting

Real-time scenarios where VARIABLE SUBSTITUTION/EXPANSION is useful

Hi, at academic level I am familiar with how variable substitution/expansion feature works. From your live experience, can you please tell what are real-time scenarios where ${variable:=} ${variable%pattern} ${variable:=word} sort of features can be used? How can we connect that dot that... (6 Replies)
Discussion started by: ab_2010
6 Replies

10. Shell Programming and Scripting

Expansion of variable inside Single Quotes Fails!!

I am unable to expand the value of entry variable inside the nawk command. I tried three different nawk command as below but none of them substitute the value of entry variable. ls *.txt | while IFS='' read -r entry; do #nawk '/<name>/{A=1;++i} A{print >> ("cmd"i"_"$entry)}... (9 Replies)
Discussion started by: mohtashims
9 Replies
Bio::Tools::Phylo::PAML::Codeml(3pm)			User Contributed Perl Documentation		      Bio::Tools::Phylo::PAML::Codeml(3pm)

NAME
Bio::Tools::Phylo::PAML::Codeml - Parses output from the PAML program codeml. SYNOPSIS
#!/usr/bin/perl -Tw use strict; use Bio::Tools::Phylo::PAML::Codeml; # need to specify the output file name (or a fh) (defaults to # -file => "codeml.mlc"); also, optionally, the directory in which # the other result files (rst, 2ML.dS, etc) may be found (defaults # to "./") my $parser = new Bio::Tools::Phylo::PAML::Codeml::Parser (-file => "./results/mlc", -dir => "./results/"); # get the first/next result; a Bio::[...]::Codeml::Result object my $result = $parser->next_result(); # get the sequences used in the analysis; returns Bio::PrimarySeq # objects (OTU = Operational Taxonomic Unit). my @otus = $result->get_seqs(); # codon summary: codon usage of each sequence [ arrayref of { # hashref of counts for each codon } for each sequence and the # overall sum ], and positional nucleotide distribution [ arrayref # of { hashref of frequencies for each nucleotide } for each # sequence and overall frequencies ]. my ($codonusage, $ntdist) = $result->get_codon_summary(); # example manipulations of $codonusage and $ntdist: printf "There were %d '%s' codons in the first seq (%s) ", $codonusage->[0]->{AAA}, 'AAA', $otus[0]->id(); printf "There were %d '%s' codons used in all the sequences ", $codonusage->[$#{$codonusage}]->{AAA}, 'AAA'; printf "Nucleotide '%c' was present %g of the time in seq %s ", 'A', $ntdist->[1]->{A}, $otus[1]->id(); # get Nei & Gojobori dN/dS matrix: my $NGmatrix = $result->get_NGmatrix(); # get ML-estimated dN/dS matrix, if calculated; this corresponds to # the runmode = -2, pairwise comparison usage of codeml my $MLmatrix = $result->get_MLmatrix(); # These matrices are length(@otu) x length(@otu) "strict lower # triangle" 2D-matrices, which means that the diagonal and # everything above it is undefined. Each of the defined cells is a # hashref of estimates for "dN", "dS", "omega" (dN/dS ratio), "t", # "S" and "N". If a ML matrix, "lnL" will also be defined. Any # additional ML parameters estimated by the model will be in an # array ref under "params"; it's up to the user to know which # position corresponds to which parameter (since PAML doesn't label # them, and we can't guess very well yet (a TODO I guess). printf "The omega ratio for sequences %s vs %s was: %g ", $otus[0]->id, $otus[1]->id, $MLmatrix->[0]->[1]->{omega}; # with a little work, these matrices could also be passed to # Bio::Tools::Run::Phylip::Neighbor, or other similar tree-building # method that accepts a matrix of "distances" (using the LOWTRI # option): my $distmat = [ map { [ map { $$_{omega} } @$_ ] } @$MLmatrix ]; # for runmode's other than -2, get tree topology with estimated # branch lengths; returns a Bio::Tree::TreeI-based tree object with # added PAML parameters at each node my $tree = $result->get_tree(); for my $node ($tree->get_nodes()) { # inspect the tree: the "t" (time) parameter is available via # $node->branch_length(); all other branch-specific parameters # ("omega", "dN", etc.) are available via $node->param('omega'); } # get any general model parameters: kappa (the # transition/transversion ratio), NSsites model parameters ("p0", # "p1", "w0", "w1", etc.), etc. my $params = $result->get_model_params(); printf "M1 params: p0 = %g p1 = %g ", $params->{p0}, $params->{p1}; # for NSsites models, obtain posterior probabilities for membership # in each class for every position; probabilities correspond to # classes w0, w1, ... etc. my @probs = $result->get_posteriors(); # find, say, positively selected sites! if ($params->{w2} > 1) { for (my $i = 0; $i < @probs ; $i++) { if ($probs[$i]->[2] > 0.5) { # assumes model M1: three w's, w0, w1 and w2 (positive selection) printf "position %d: (%g prob, %g omega, %g mean w) ", $i, $probs[$i]->[2], $params->{w2}, $probs[$i]->[3]; } } } else { print "No positive selection found! "; } DESCRIPTION
This module is used to parse the output from the PAML program codeml. You can use the Bio::Tools::Run::Phylo::Phylo::PAML::Codeml module to actually run codeml; this module is only useful to parse the output. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/MailList.shtml - About the mailing lists Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via email or the web: bioperl-bugs@bioperl.org http://bioperl.org/bioperl-bugs/ AUTHOR - Jason Stajich, Aaron Mackey Email jason@bioperl.org Email amackey@virginia.edu TODO
This module should also be able to handle "codemlsites" batch output... APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $obj = new Bio::Tools::Phylo::PAML::Codeml(); Function: Builds a new Bio::Tools::Phylo::PAML::Codeml object Returns : Bio::Tools::Phylo::PAML::Codeml Args : get_trees Title : get_trees Usage : my @trees = $codemlparser->get_trees(); Function: Returns a list of trees (if any) are in the output file Returns : List of L<Bio::Tree::TreeI> objects Args : none get_statistics Title : get_statistics Usage : my $data = $codemlparser->get_statistics Function: Retrieves the set of pairwise comparisons Returns : Hash Reference keyed as 'seqname' -> 'seqname' -> 'datatype' Args : none perl v5.14.2 2012-03-02 Bio::Tools::Phylo::PAML::Codeml(3pm)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy