Sponsored Content
Top Forums Shell Programming and Scripting Replacing individual characters with a pattern. Post 302576316 by ahamed101 on Thursday 24th of November 2011 09:25:35 AM
Old 11-24-2011
Try this...
Code:
#Variation 1
awk '{ for(i=1;i<=NF;i++) {
                if($i~"=") {
                        l=length($i)-1
                        if($i~"[\\.,]$"){
                          l=l-1; e=substr($i,l+2,l) }
                        for(j=1;j<=l;j++) p=p"_ ";
                        $i=p;printf $i e OFS;p="";e=""
                } else { printf $i OFS }
        }printf "\n" } ' input_file

#Variation 2
awk '{ for(i=1;i<=NF;i++) {
                if($i~"=") {
                        l=length($i)-1
                        if($i~"[\\.,]$"){
                          l=l-1; e=substr($i,l+2,l) }
                        s=substr($i,2,1);
                        for(j=2;j<=l;j++) p=p"_ ";
                        $i=p;printf s $i e OFS;p="";e=""
                } else { printf $i OFS }
        }printf "\n" } ' input_file

--ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

replacing few characters in a file

Hi All, I have huge xml file. The file contains some comment tags . I have requirement to replace comment tag with another comment tag. Say for example : file X has -- Part of the file <?xml version="1.0" encoding="ISO-2"?><translationResults jobDate="20070123 23:20:51"... (1 Reply)
Discussion started by: purnakarthik
1 Replies

2. UNIX for Dummies Questions & Answers

replacing characters

Hi, I have a script for replacing bad characters in filenames for f in *; do mv $f `echo $f | tr '+' '_'` done; this replaces + for _ But I need to replace all bad characters ? / % + to _ Pls how can i do this in one script ? (3 Replies)
Discussion started by: palmer18
3 Replies

3. Shell Programming and Scripting

replacing characters

hi all I have a file that has sone spaces in start then / at last. i want to get rid of this. how to do? eg. 11414/ 49878/ 27627/ I WANT THE FILE AS 11414 49878 27627 PLEASE HELP (3 Replies)
Discussion started by: infyanurag
3 Replies

4. Shell Programming and Scripting

Replacing Characters

Hi All, I have a file which is delimeted with the character '. i need to replace this character with the same character and also a new line. Can anyone please help me with the tr command for this. Many thanks Karan (11 Replies)
Discussion started by: karansachdeva
11 Replies

5. Shell Programming and Scripting

Replacing Characters with |

Hi All, example data.log 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 526569346 66815531961 09 I want like this to 526569346|66815531961|09 526569346|66815531961|09... (4 Replies)
Discussion started by: ooilinlove
4 Replies

6. Shell Programming and Scripting

Replacing characters

Hi fellow experts, I have a question for you. Data looks like: 00877,05/13/2010,PBO,P,0000708331,518 00877,05/13/2010,PBO,P,0000708331,519 ... ... 00877,05/13/2010,PBO,P,0000708331,2103 00877,05/13/2010,PBO,P,0000708331,2104,etc,etc Basically I have to replace 518,519,2103,2104,... (4 Replies)
Discussion started by: Devski123
4 Replies

7. Shell Programming and Scripting

Replacing Complex Characters in vi

ok, so i have a number of commands like the below in a script: /usr/bin/awk "/ I need to replace the bolded with "^\ but i'm having tremendous difficulties accomplishing this. This needs to be done in vi. can someone please help me out? (4 Replies)
Discussion started by: SkySmart
4 Replies

8. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

9. Shell Programming and Scripting

Replacing a pattern in different cases in different columns with a single pattern

Hi All I am having pipe seperated inputs like Adam|PeteR|Josh|PEter Nick|Rave|Simon|Paul Steve|smith|PETER|Josh Andrew|Daniel|StAlin|peter Rick|PETer|ADam|RAVE i want to repleace all the occurrence of peter (in any case pattern PeteR,PEter,PETER,peter,PETer) with Peter so that output... (5 Replies)
Discussion started by: sudeep.id
5 Replies

10. Shell Programming and Scripting

Finding the pattern and replacing the pattern inside the file

i have little challenge, help me out.i have a file where i have a value declared and and i have to replace the value when called. for example i have the value for abc and ccc. now i have to substitute the value of value abc and ccc in the place of them. Input File: go to &abc=ddd; if... (16 Replies)
Discussion started by: saaisiva
16 Replies
Bio::Variation::AAChange(3pm)				User Contributed Perl Documentation			     Bio::Variation::AAChange(3pm)

NAME
Bio::Variation::AAChange - Sequence change class for polypeptides SYNOPSIS
$aamut = Bio::Variation::AAChange->new ('-start' => $start, '-end' => $end, '-length' => $len, '-proof' => $proof, '-isMutation' => 1, '-mut_number' => $mut_number ); my $a1 = Bio::Variation::Allele->new; $a1->seq($ori) if $ori; $aamut->allele_ori($a1); my $a2 = Bio::Variation::Allele->new; $a2->seq($mut) if $mut; $aachange->add_Allele($a2); $aachange->allele_mut($a2); print " "; # add it to a SeqDiff container object $seqdiff->add_Variant($rnachange); # and create links to and from RNA level variant objects $aamut->RNAChange($rnachange); $rnachange->AAChange($rnachange); DESCRIPTION
The instantiable class Bio::Variation::RNAChange describes basic sequence changes at polypeptide level. It uses methods defined in superclass Bio::Variation::VariantI, see Bio::Variation::VariantI for details. If the variation described by a AAChange object has a known Bio::Variation::RNAAChange object, create the link with method AAChange(). See Bio::Variation::AAChange for more information. 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 lists Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Heikki Lehvaslaiho Email: heikki-at-bioperl-dot-org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ RNAChange Title : RNAChange Usage : $mutobj = $self->RNAChange; : $mutobj = $self->RNAChange($objref); Function: Returns or sets the link-reference to a mutation/change object. If there is no link, it will return undef Returns : an obj_ref or undef label Title : label Usage : $obj->label(); Function: Sets and returns mutation event label(s). If value is not set, or no argument is given returns false. Each instantiable subclass of L<Bio::Variation::VariantI> needs to implement this method. Valid values are listed in 'Mutation event controlled vocabulary' in http://www.ebi.ac.uk/mutations/recommendations/mutevent.html. Example : Returns : string Args : string similarity_score Title : similarity_score Usage : $self->similarity_score Function: Measure for evolutionary conservativeness of single amino substitutions. Uses BLOSUM62. Negative numbers are noncoservative changes. Returns : integer, undef if not single amino acid change trivname Title : trivname Usage : $self->trivname Function: Given a Bio::Variation::AAChange object with linked Bio::Variation::RNAChange and Bio::Variation::DNAMutation objects, this subroutine creates a string corresponding to the 'trivial name' of the mutation. Trivial name is specified in Antonorakis & MDI Nomenclature Working Group: Human Mutation 11:1-3, 1998. Returns : string perl v5.14.2 2012-03-02 Bio::Variation::AAChange(3pm)
All times are GMT -4. The time now is 08:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy