Sponsored Content
Top Forums Shell Programming and Scripting Help: Parsing a file to new output files Post 302754363 by fozrun on Thursday 10th of January 2013 01:06:57 PM
Old 01-10-2013
Help: Parsing a file to new output files

I have an output file similar to this

Code:
>HWI-ST766:129:D0WJDACXX:4:2308:16645:199681.1 /start=1 /end=100 /strand=+ Eukaryotic18S_rRNA
GATTAAGCCATGCATGTGTAAGTTTAAAGTCCTAGAAGGATGAAACTGCGGACGGCTCAT
TATAACAGTAATAGTTTCTTTGGTTAGTATCTATAAGGAT
>HWI-ST766:129:D0WJDACXX:4:2308:2922:199946.1 /start=1 /end=96 /strand=+ Eukaryotic:28S_rRNA
CCTAACTATACGCTCATCAGATACCACAAAAGGTGTTGATTCATCTAAACAGCAGGGCGG
TGGACATAGAAGTCGTTACCCGCTAAGGAGTGTGTC
>HWI-ST766:129:D0WJDACXX:4:2308:5144:199799.1 /start=1 /end=85 /strand=- Bacterial:16S_rRNA
GGGGAGATCTCAAAGAGTCAGGTTGCTTGGAACTGCAGCCTTAAGCGGGAGATATGAAAC
TTCCAAAGCTAAATATAGATGGGAG
>HWI-ST766:129:D0WJDACXX:4:2308:7062:199913.1 /start=2 /end=100 /strand=+ Bacterial:23S_rRNA
TTCGAGTTGGAGCACGCCTGTCGGGACCCGAAAGATGGTGAACTATGCCTGAGCGGGGCG
AAGCCAGAGGAAACTCTGGTGGAGGCTCGAAGCGATACT
>HWI-ST766:129:D0WJDACXX:4:2308:13310:199841.1 /start=10 /end=99 /strand=+ Archaeal:16S_rRNA
AACACAAACTAGCTTGGAGACATCAGCACGTGCCCTTGGAAGAGTTTTCTTTTCTTCTTA
ACATGTATGAGGCCTTGAAATTGGATTACC
>HWI-ST766:129:D0WJDACXX:4:2308:15549:199820.1 /start=1 /end=100 /strand=- Archaeal:23S_rRNA
CCTCAGGATAGCAGGAACAATATTGCAGTTTTATCAGGTAAAGCGAATGATTAGAGGTTA
CTGAGCGTTTTTTGTTTGGACCTATTCTCAAACTTTAAAT
>HWI-ST766:129:D0WJDACXX:4:2308:1510:200068.1 /start=1 /end=100 /strand=- Bacterial:23S_rRNA
GAAGCGGTGTTGACGTGCAAATCACTCGTCAAATTTGGGTATAGGGGCGAAAGACTAATC
GAACCATCTAGTAGCTGGTTCCCTCTGAAGTTTCCCTCAG
>HWI-ST766:129:D0WJDACXX:4:2308:2254:200148.1 /start=1 /end=100 /strand=- Archaeal:23S_rRNA
GATGGTGAACTATACTTGAACGGTTAGAAGCCGAAGGAAACTTTGGTGGAAGAACCACGC
AGTGTTAACGTGCAAATTACTTGTCATATTTGAGTATAGG
>HWI-ST766:129:D0WJDACXX:4:2308:4747:200053.1 /start=2 /end=96 /strand=+ Eukaryotic:28S_rRNA
AGATGACTCGCTGGACTTAAGCATATTATTAAGCGAAGGAAAAGAAATTAACAAAGATTG
CCTTAGTAAGGGCGACTGAACCGGCAATAGCTCGA
>HWI-ST766:129:D0WJDACXX:4:2308:4747:200053.1 /start=2 /end=96 /strand=+ Bacterial:16S_rRNA
AGATGACTCGCTGGACTTAAGCATATTATTAAGCGAAGGAAAAGAAATTAACAAAGATTG
CCTTAGTAAGGGCGACTGAACCGGCAATAGCTCGA
>HWI-ST766:129:D0WJDACXX:4:2308:5396:200008.1 /start=2 /end=100 /strand=+ Eukaryotic18S_rRNA
TTCTTAGTGGGCCATTTTTGGTAAGCAGAACTGGCGATGAGGGATGAACCTAACGTCGAG
TTAAGGTGCCTAACTATACGCTCATCAGATACCACAAAA

I would like to search the file and create new output files based on the different rRNA types. The six are Eukaryotic18S_rRNA Eukaryotic:28S_rRNA Bacterial:16S_rRNA Bacterial:23S_rRNA Archaeal:16S_rRNA Archaeal:23S_rRNA (note the missing : in Eukaryotic18S_rRNA is real, a mistake in the original program)

So a search for Bacterial:16S_rRNA would output to a different file

Code:
>HWI-ST766:129:D0WJDACXX:4:2308:5144:199799.1 /start=1 /end=85 /strand=- Bacterial:16S_rRNA
GGGGAGATCTCAAAGAGTCAGGTTGCTTGGAACTGCAGCCTTAAGCGGGAGATATGAAAC
TTCCAAAGCTAAATATAGATGGGAG
>HWI-ST766:129:D0WJDACXX:4:2308:4747:200053.1 /start=2 /end=96 /strand=+ Bacterial:16S_rRNA
AGATGACTCGCTGGACTTAAGCATATTATTAAGCGAAGGAAAAGAAATTAACAAAGATTG
CCTTAGTAAGGGCGACTGAACCGGCAATAGCTCGA

The input file could be searched serially for each key, or all at the same time, ouputing to different files. The input files are a few GB in size (but I do have a lot of memory).

Any help would be appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem parsing output file

Hi Gurus, I am using the following code to parse the output of a file. This code basically parses the file and adds | at the end of each field. But I am getting it wrong in some cases. I have explained it below #----- parse output file, get each field position, ----- #----- and construct... (13 Replies)
Discussion started by: ragha81
13 Replies

2. Shell Programming and Scripting

parsing output

I have a file that contains the output of the ls -iR command, something like this: ./results: 2504641011 result_1410 2500957642 result_525 2504641012 result_1425 2500957643 result_540 ./tests/1: 2500788755 1 2500788743 1000 ./tests/2: 2500788759 3 2500788758 999 ... (6 Replies)
Discussion started by: looza
6 Replies

3. Shell Programming and Scripting

need help in Parsing a CSV file and generate a new output file

Hi Scripting Gurus, I am trying to parse a csv file and generate a new output file. The input file will be a variable length in turns of rows and columns. output file will have 8 columns. we have three columns from the header for each set. just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies

4. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

5. Shell Programming and Scripting

parsing file names and then grouping similar files

Hello Friends, I have .tar files which exists under different directories after the below code is run: find . -name "*" -type f -print | grep .tar > tmp.txt cat tmp.txt ./dir1/subdir1/subdir2/database-db1_28112009.tar ./dir2/subdir3/database-db2_28112009.tar... (2 Replies)
Discussion started by: EAGL€
2 Replies

6. Shell Programming and Scripting

parsing txt file, saving graphics files

hi everyone, i am a newbie in shell programming. and i want to simply go through a text file that contains 3 "columns", split by ';' customerID ; link-to-contract ; save-as-filename so an example would simply look like this now i want to loop through every line, and save the file from... (3 Replies)
Discussion started by: Confidence
3 Replies

7. Shell Programming and Scripting

Parsing txt, xml files and preparing csv file

Hi, I need to parse text, xml files to get the statistic numbers and prepare summary csv file. What is the best way to parse these file and prepare csv file. Any idea you have , please? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

8. Shell Programming and Scripting

Parsing fields from class list files to use output with newusers command

Hello I am trying to develop a shell script that takes a text file such as this... E-mail@ Soc.Sec.No. *--------Name-----------* Class *School.Curriculum.Major.* Campus.Phone JCC2380 XXX-XX-XXXX CAREY, JULIE C JR-II BISS CPSC BS INFO TECH 412/779-9445 JAC1936 XXX-XX-XXXX... (7 Replies)
Discussion started by: crimputt
7 Replies

9. Shell Programming and Scripting

Help in parsing XML output file in perl.

Hi I have an XML output like : <?xml version="1.0" encoding="ISO-8859-1" ?> - <envelope> - <body> - <outputGetUsageSummary> - <usgSumm rerateDone="5"> - <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false"... (7 Replies)
Discussion started by: rkrish
7 Replies

10. UNIX for Dummies Questions & Answers

Help on parsing Oracle RMAN output for string and print sections of a file

Hi, I need some advise on how to print 'sections' of the attached file. I am searching for some that says Marked Corrupt and print some lines after it. At the moment I am running the command below: sed -n -e '/Marked Corrupt/{N;N;p;}' rman_list_validate.txtThis gives me the following... (1 Reply)
Discussion started by: newbie_01
1 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 02:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy