Sponsored Content
Top Forums Shell Programming and Scripting Outputting sequences based on length with sed Post 303026297 by Xterra on Friday 23rd of November 2018 07:09:23 PM
Old 11-23-2018
Outputting sequences based on length with sed

I have this file:
Code:
>ID1
AA
>ID2
TTTTTT
>ID-3
AAAAAAAAA
>ID4
TTTTTTGGAGATCAGTAGCAGATGACAG-GGGGG-TGCACCCC

Add I am trying to use this script to output sequences longer than 15 characters:
Code:
sed -r '/^>/N;{/^.{,15}$/d}'

The desire output would be this:
Code:
>ID4
TTTTTTGGAGATCAGTAGCAGATGACAG-GGGGG-TGCACCCC

I am also trying to output the sequences that are shorter than 15 characters using the following script:
Code:
sed -rn '/^>/N;{/^.{,15}$/p}'

The desire output is:
Code:
>ID1
AA
>ID2
TTTTTT
>ID-3
AAAAAAAAA

How can I modify my scripts so I can generate the desire outputs?
Thanks in advance
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sed working on lines of small length and not large length

Hi , I have a peculiar case, where my sed command is working on a file which contains lines of small length. sed "s/XYZ:1/XYZ:3/g" abc.txt > xyz.txt when abc.txt contains lines of small length(currently around 80 chars) , this sed command is working fine. when abc.txt contains lines of... (3 Replies)
Discussion started by: thanuman
3 Replies

2. Shell Programming and Scripting

Trimming sequences based on specific pattern

My files look like this And I need to cut the sequences at the last "A" found in the following 'pattern' -highlighted for easier identification, the pattern is the actual file is not highlighted. The expected result should look like this Thus, all the sequences would end with AGCCCTA... (2 Replies)
Discussion started by: Xterra
2 Replies

3. Shell Programming and Scripting

Deleting sequences based on character frequency

This is what I would like to accomplish, I have an input file (file A) that consist of thousands of sequence elements with the same number of characters (length), each headed by a free text header starting with the chevron ‘>' character followed by the ID (all different IDs with different lenghts)... (9 Replies)
Discussion started by: Xterra
9 Replies

4. Shell Programming and Scripting

Trimming sequences based on Reference

My file looks something like this Wnat I need is to look for the Reference sequence (">Reference1") and based on the length of that sequence trim all the entries in that file. So, the rersulting file will contain all sequences with the same length, like this Thus, all sequences will keep... (5 Replies)
Discussion started by: Xterra
5 Replies

5. Shell Programming and Scripting

Extract sequences based on the list

Hi, I have a file with more than 28000 records and it looks like below.. >mm10_refflat_ABCD range=chr1:1234567-2345678 tgtgcacactacacatgactagtacatgactagac....so on >mm10_refflat_BCD range=chr1:3234567-4545678... tgtgcacactacacatgactagtatgtgcacactacacatgactagta . . . . . so on ... (2 Replies)
Discussion started by: Diya123
2 Replies

6. Shell Programming and Scripting

Extract length wise sequences from fastq file

I have a fastq file from small RNA sequencing with sequence lengths between 15 - 30. I wanted to filter sequence lengths between 21-25 and write to another fastq file. how can i do that? (4 Replies)
Discussion started by: empyrean
4 Replies

7. Shell Programming and Scripting

Selecting sequences based on scores

I have two files with thousands of sequences of different lengths. infile1 contains the actual sequences and infile2 the scores for each A, T, G and C in infile1. Something like this: infile1: >HZVJKYI01ECH5R TTGATGTGCCAGCTGCCGTTGGTGTGCCAA >HZVJKYI01AQWJ8 GGATATGATGATGAACTGGTTTGGCACACC... (4 Replies)
Discussion started by: Xterra
4 Replies

8. Shell Programming and Scripting

Eliminating sequences based on Distances

I have to remove sequences from a file based on the distance value. I am attaching the file containing the distances (Distance.xls) The second file looks something like this: Sequences.txt >Sample1 Freq 59 ggatatgatgatgaactggt >Sample1 Freq 54 ggatatgatgttgaactggt >Sample1 Freq 44... (2 Replies)
Discussion started by: Xterra
2 Replies

9. Shell Programming and Scripting

Print sequences from file2 based on match to, AND in same order as, file1

I have a list of IDs in file1 and a list of sequences in file2. I can print sequences from file2, but I'm asking for help in printing the sequences in the same order as the IDs appear in file1. file1: EN_comp12952_c0_seq3:367-1668 ES_comp17168_c1_seq6:1-864 EN_comp13395_c3_seq14:231-1088... (5 Replies)
Discussion started by: pathunkathunk
5 Replies

10. UNIX for Beginners Questions & Answers

How to count the length of fasta sequences?

I could calculate the length of entire fasta sequences by following command, awk '/^>/{if (l!="") print l; print; l=0; next}{l+=length($0)}END{print l}' unique.fasta But, I need to calculate the length of a particular fasta sequence specified/listed in another txt file. The results to to be... (14 Replies)
Discussion started by: dineshkumarsrk
14 Replies
jiskanji(5)							File Formats Manual						       jiskanji(5)

NAME
jiskanji, jiskanji7, JIS7 - A character encoding system (codeset) for Japanese DESCRIPTION
JIS Kanji is a codeset that uses the JIS X0202 symbol extension method for encoding the JIS X0208 and JIS X0201 character sets. There are two types of JIS Kanji encoding: 7-bit JIS Kanji code and 8-bit JIS Kanji code. 7-bit JIS Kanji Code In 7-bit JIS Kanji encoding, all character values are 7-bit bytes. Characters are interpreted according to preceding in and out sequences as follows: Kanji in sequence (ESC $ B) The code values following the Kanji in sequence (ESC $ B) are treated as characters in the JIS X0208 Kanji character set. Kanji out sequence (ESC ( B) The code values following the Kanji out sequence (ESC ( B) are treated as ASCII characters. Supplementary Kanji in sequence (ESC $ ( D) The code values following the supplementary Kanji in sequence (ESC $ ( D) are treated as characters in the JIS X0212 supplementary Kanji character set. User-Defined Character (UDC) in sequence (ESC $ ( 0) The code values following the UDC in sequence (ESC $ ( 0) are treated as characters in the vendor-defined or user-defined character set. Kana in (SO) and Kana out (SI) sequences The code values following SO(0x0e) and preceding SI(0x0f) are treated as characters in the JIS X0201 Katakana character set. Katakana in sequence (ESC ( I) Code values following the Katakana in sequence (ESC ( I) are treated as characters in the JIS X0201 Katakana character set. In this case, the Kanji out sequence is used to switch back to ASCII code. The Katakana in and Kanji out sequences are an alternative to using the Kana in and out sequences (SO/SI). 8-bit JIS Kanji Code In 8-bit JIS Kanji encoding, the JIS X0201 Katakana characters are represented as 8-bit bytes. Using this form of encoding, in and out sequences have the following effect: Kanji in sequence (ESC $ B) Code values following the Kanji in sequence (ESC $ B) are treated as characters in the JIS X0208 Kanji character set. Supplementary Kanji in sequence (ESC $ ( D) Code values following the supplementary Kanji in sequence (ESC $ ( D) are treated as characters in the JIS X0212 supplementary Kanji character set. User-Defined Character (UDC) in sequence (ESC $ ( 0) Code values following the UDC in sequence (ESC $ ( 0) are treated as vendor-defined or user-defined characters. Kanji out sequence (ESC ( B) Code values following the Kanji out sequence (ESC ( B) are treated as ASCII characters. Kana in and out sequences (SI/SO) These sequences are ignored. Codeset Conversion The following codeset converter pairs are available for converting Japanese characters between jiskanji7 or JIS7 and other encoding for- mats. The RESTRICTIONS section discusses some conversion limitations that apply to these converters. Refer to iconv_intro(5) for an introduction to codeset conversion. For more information about the other codeset for which jiskanji7 or JIS7 is the input or output, see the reference page specified in the list item. deckanji_jiskanji7 or deckanji_JIS7, jiskanji7_deckanji or JIS7_deckanji Converting from and to the DEC Kanji codeset: deckanji(5). eucJP_jiskanji7 or eucJP_JIS7, jiskanji7_eucJP or JIS7_eucJP Converting from and to Japanese Extended UNIX Code: eucJP(5). eucTW_jiskanji7 or eucTW_JIS7, jiskanji7_eucTW or JIS7_eucTW Converting from and to Taiwanese Extended UNIX Code: eucTW(5). sdeckanji_jiskanji7 or sdeckanji_JIS7, jiskanji7_sdeckanji or JIS7_sdeckanji Converting from and to the Super DEC Kanji codeset: sdeckanji(5). SJIS_jiskanji7 or SJIS_JIS7, jiskanji7_SJIS or JIS7_SJIS Converting from and to Shift JIS format: SJIS(5). Shift JIS encoding format is identical to encoding in Microsoft code-pages used on PC systems. Therefore, you can use these convert- ers to convert Japanese characters between JIS Kanji and PC code-page format. For general information on how the operating system supports PC code pages, see code_page(5). RESTRICTIONS
The JIS Kanji codeset is not supported directly by a locale but through code conversion (through the iconv utility, Japanese terminal (tty) code conversion, and so forth). In the codeset naming conventions used by the iconv utility, the string JIS7 indicates 7-bit JIS Kanji code that follows a Katakana in sequence and the string jiskanji7 indicates 7-bit JIS Kanji code entered between Kana in and out sequences. The following sequences are valid for input to the iconv utility but are not generated when code is converted to jiskanji7: Kanji in (ESC $ @) Kanji in (ESC & @ ESC $ B) Kanji in (ESC $ ( B) Kanji in (ESC $ ( @) Supplementary Kanji in (ESC $ D) Kana in (ESC ( J) Kana in (ESC ( H) In the code naming conventions of the Japanese terminal, the string jis7 indicates 7-bit JIS Kanji code and the string jis8 indicates 8-bit JIS Kanji code. When the terminal code is set to jis7, the Kana in and out sequences (SI/SO) are used for JIS X0201 Katakana character rep- resentation. SEE ALSO
Commands: locale(1) Others: ascii(5), code_page(5), deckanji(5), eucJP(5), i18n_intro(5), i18n_printing(5), iconv_intro(5), iso2022jp(5), Japanese(5), l10n_intro(5), sdeckanji(5), shiftjis(5) jiskanji(5)
All times are GMT -4. The time now is 04:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy