Sponsored Content
Top Forums Shell Programming and Scripting Program to match the id and replace one letter in the content Post 302840179 by kaav06 on Monday 5th of August 2013 12:30:44 AM
Old 08-05-2013
Program to match the id and replace one letter in the content

Hi all,
I have one file with a sequence and the other file which says the position and the letter to be changed. I have to match two files and replace content. Example is shown which will describe what I want to do. For example, file 1 has many sequences and few are shown below

sequence file:
Code:
>sp|P78363|ABCA4_HUMAN Retinal-specific ATP-binding cassette transporter OS=Homo sapiens GN=ABCA4 PE=1 SV=3
MGFVRQIQLLLWKNWTLRKRQKIRFVVELVWPLSLFLVLIWLRNANPLYSHHECHFPNKA
MPSAGMLPWLQGIFCNVNNPCFQSPTPGESPGIVSNYNNSILARVYRDFQELLMNAPESQ
>sp|P21439|MDR3_HUMAN Multidrug resistance protein 3 OS=Homo sapiens GN=ABCB4 PE=1 SV=2
MDLEAAKNGTAWRPTSAEGDFELGISSKQKRKKTKTVKMIGVLTLFRYSDWQDKLFMSLG
TIMAIAHGSGLPLMMIVFGEMTDKFVDTAGNFSFPVNFSLSLLNPGKILEEEMTRYAYYY

and the second file has the id which is enclosed in between || in the first file and the letters to be changed. Now I have to match the id column with the header line in the seuqence file |P78363|. if they are same, do the change as mentioned and write in the output file.
Code:
Id         Orginial letter Position to be chnaged to 
P78363        M              1             T
P78363        G              2              E
P21439        L               3              A

the output file should contain the sequences of the changed letters and the change name in the header as highlighted (bold) in the below code
Code:
>sp|P78363|M1T ABCA4_HUMAN Retinal-specific ATP-binding cassette transporter OS=Homo sapiens GN=ABCA4 PE=1 SV=3
TGFVRQIQLLLWKNWTLRKRQKIRFVVELVWPLSLFLVLIWLRNANPLYSHHECHFPNKA
MPSAGMLPWLQGIFCNVNNPCFQSPTPGESPGIVSNYNNSILARVYRDFQELLMNAPESQ
>sp|P78363|G2E ABCA4_HUMAN Retinal-specific ATP-binding cassette transporter OS=Homo sapiens GN=ABCA4 PE=1 SV=3
MEFVRQIQLLLWKNWTLRKRQKIRFVVELVWPLSLFLVLIWLRNANPLYSHHECHFPNKA
MPSAGMLPWLQGIFCNVNNPCFQSPTPGESPGIVSNYNNSILARVYRDFQELLMNAPESQ
>sp|P21439|L3A MDR3_HUMAN Multidrug resistance protein 3 OS=Homo sapiens GN=ABCB4 PE=1 SV=2
MDAEAAKNGTAWRPTSAEGDFELGISSKQKRKKTKTVKMIGVLTLFRYSDWQDKLFMSLG
TIMAIAHGSGLPLMMIVFGEMTDKFVDTAGNFSFPVNFSLSLLNPGKILEEEMTRYAYYY

Could anyone please help with a script which can do this. It will be bery helpful
Note: this is not a school exercise.

Thanks
Kaavya
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find out the match data content?!

Hi, Long list of Input file1 content: 1285_t 4860_i 4817_v 8288_c 9626_a . . . Long list of Input file2 content: 1285_t chris germany 8288_c steve england 9626_a dave swiss 9260_s stephanie denmark . . . (14 Replies)
Discussion started by: patrick87
14 Replies

2. Shell Programming and Scripting

Extract all content that match exactly only specific word

Input: 21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set; 21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11; 21 templeta ... (7 Replies)
Discussion started by: patrick87
7 Replies

3. Shell Programming and Scripting

Column content match and add suffix

My input chr3 galGal3_xenoRefFlat CDS 4178235 4178264 0.000000 + 0 gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19; T6J4_19"; chr3 galGal3_xenoRefFlat exon 4178235 4178264 0.000000 + . gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19;... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. Shell Programming and Scripting

Letter Frequency Decryption Program in Perl

Hello, :/ (0 Replies)
Discussion started by: jvr42
0 Replies

5. Shell Programming and Scripting

Upper case letter match

Hi, im able to search for string in a file (ex: grep -w "$a" input.txt). but i have to search for the uppercase of a string in a file where upper case of the file content matches something like below. where upper("$a")== converted to upper case string in (input.txt) can someone please provide... (5 Replies)
Discussion started by: p_satyambabu
5 Replies

6. Shell Programming and Scripting

Sorting content between match pattern and move on with awk and sed

S 0.0 0.0 (reg, inst050) k e f d c S 0.0 0.0 (mux, m030) k g r s x v S 0.0 0.0 (reg, inst020) q s n m (12 Replies)
Discussion started by: ctphua
12 Replies

7. Shell Programming and Scripting

Replace specific letter in a file by other letter

Good afternoon all, I want to ask how to change some letter in my file with other letter in spesific line eg. data.txt 1 1 1 0 0 0 0 for example i want to change the 4th line with character 1. How could I do it by SED or AWK. I have tried to run this code but actually did not... (3 Replies)
Discussion started by: weslyarfan
3 Replies

8. Shell Programming and Scripting

Replace the first letter of each line by a capital

Hi, I need to replace, as the title says, the first letter of each line (when it's not a number) by the same letter, but capital. For instance : hello Who 123pass Would become : Hello Who 123pass Is there a way with sed to do that ? Or other unix command ? Thank you :) (7 Replies)
Discussion started by: ganon551
7 Replies

9. UNIX for Dummies Questions & Answers

Replace space in column with letter for several rows

I have a pbd file, which has the following format: TITLE Protein X MODEL 1 ATOM 1 N PRO 24 45.220 71.410 43.810 1.00 0.00 ATOM 2 H1 PRO 24 45.800 71.310 42.000 1.00 0.00 TER ENDMDL Column 22 is the chain... (5 Replies)
Discussion started by: Egy
5 Replies

10. Shell Programming and Scripting

awk command to get file content until 2 occurrence of pattern match

AWK command to get file content until 3 occurrence of pattern match, INPUT FILE: JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2"> <person>Romi</person> <appName>SAP</appName> </custOptIn> ... (4 Replies)
Discussion started by: prince1987
4 Replies
REPLACE(1)						       MySQL Database System							REPLACE(1)

NAME
replace - a string-replacement utility SYNOPSIS
replace arguments DESCRIPTION
The replace utility program changes strings in place in files or on the standard input. Invoke replace in one of the following ways: shell> replace from to [from to] ... -- file_name [file_name] ... shell> replace from to [from to] ... < file_name from represents a string to look for and to represents its replacement. There can be one or more pairs of strings. Use the -- option to indicate where the string-replacement list ends and the file names begin. In this case, any file named on the command line is modified in place, so you may want to make a copy of the original before converting it. replace prints a message indicating which of the input files it actually modifies. If the -- option is not given, replace reads the standard input and writes to the standard output. replace uses a finite state machine to match longer strings first. It can be used to swap strings. For example, the following command swaps a and b in the given files, file1 and file2: shell> replace a b b a -- file1 file2 ... The replace program is used by msql2mysql. See msql2mysql(1). replace supports the following options. o -?, -I Display a help message and exit. o -#debug_options Enable debugging. o -s Silent mode. Print less information what the program does. o -v Verbose mode. Print more information about what the program does. o -V Display version information and exit. COPYRIGHT
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Sun Microsystems, Inc. (http://www.mysql.com/). MySQL 5.1 04/06/2010 REPLACE(1)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy