Sponsored Content
Top Forums Shell Programming and Scripting Filter (by max length) only lines not matching regex Post 302785149 by pathunkathunk on Monday 25th of March 2013 02:28:13 AM
Old 03-25-2013
Filter (by max length) only lines not matching regex

I have a large file of many pairs of sequences and their headers, which always begin with '>'
Quote:
>gi|abc| Species one
ATCAGGTATAATT
>gi|bcd| Species two
ATTTGATC
>gi|cdf| Species three
ATTTGATCT
I'm looking for help on how to retain only sequences (and their headers) below a certain length. So if min length was 10, output would be
Quote:
>gi|bcd| Species two
ATTTGATC
>gi|cdf| Species three
ATTTGATCT
I can filter by length, but I'm not sure how to exclude the header lines.
Code:
awk '{lines[NR] = $0} length($0) < 10 {print lines [NR-1]; print lines [NR]} ' file.name

 

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. UNIX for Dummies Questions & Answers

Length of a Unix filepath max length

Hi Guys, Could anyone shed some light on the length of a Unix filepath max length pls ? thanks ! Wilson (3 Replies)
Discussion started by: wilsontan
3 Replies

3. Shell Programming and Scripting

Counting the max length of string

Hi all, I have a flat file of 1000 rows. I want to check the length of the 5th column. The one having the longest length , I want to set it as DEFINED PARAMETER. So later I can check others with that particular number only. Any ideas ?? (2 Replies)
Discussion started by: ganesh123
2 Replies

4. UNIX for Advanced & Expert Users

How to increase max username length?

Hi, This is my first post to this site. So kindly forgive if I am writing in a wrong section. My query is that... I want to modify the max username length size. I guess it is 32/64 on CentOS. Now I want to change it to 128. Is there any way to do that? Thanks in advance!! :) (4 Replies)
Discussion started by: ajay303
4 Replies

5. UNIX for Dummies Questions & Answers

Modify the max username length

Hey Any one... Do u know any way I can modify the max username length in unix? I guess it is 32/64 characters by default. Suppose I want to increase it to 128. i hav tried /etc/skel but no use... How can I do that? (2 Replies)
Discussion started by: MayureshRisbud
2 Replies

6. Shell Programming and Scripting

Perl Regex matching multiple lines

I need a way to extract data from X 4T Solution 21 OCT 2011 37 .00 to account 12345678 User1 user2 X 4T Solution Solution Unlimited 11 Sep 2009 248 .00 to account 87654321 user3 user4 I need it to extract 'X' '37.00' and account number 12345678. I have extracted above stuff... (3 Replies)
Discussion started by: chakrapani
3 Replies

7. Shell Programming and Scripting

Filter file by length, looking only at lines that don't begin with ">"

I have a file that stores data in pairs of lines, following this format: line 1: header (preceded by ">") line 2: sequence Example.txt: >seq1 name GATTGATGTTTGAGTTTTGGTTTTT >seq2 name TTTTCTTC I want to filter out the sequences and corresponding headers for all sequences that are less... (2 Replies)
Discussion started by: pathunkathunk
2 Replies

8. UNIX for Dummies Questions & Answers

awk loop for to filter lines by max value

Hi all, I'm struggling to filter my data frame. I need to print only those lines whose max value (the number of columns may vary) is above a cut-off value. My data looks like this: chr22 17565753 17565754 5 4 5 5 6 2 5 5 6 2 chr22 17565754 ... (2 Replies)
Discussion started by: lsantome
2 Replies

9. Shell Programming and Scripting

Filter all the lines with minimum specified length of words of a text file

Hi Can someone tell me which script will work best (in terms of speed and simplicity to write and run) for a large text file to filter all the lines with a minimum specified length of words ? A sample script with be definitely of great help !!! Thanks in advance. :) (4 Replies)
Discussion started by: my_Perl
4 Replies

10. Shell Programming and Scripting

Filter Row Based On Max Column Value After Group BY

Hello Team, Need your expertise on following: Here is the set of data: C1|4|C1SP1|A1|C1BP1|T1 C1|4|C1SP2|A1|C1BP2|T2 C2|3|C2SP1|A2|C2BP1|T2 C3|3|C3SP1|A3|C3BP1|T2 C2|2|C2SP2|A2|C2BP2|T1 I need to filter above date base on following two steps: 1. Group them by column 1 and 4 2.... (12 Replies)
Discussion started by: angshuman
12 Replies
Bio::SeqI(3pm)						User Contributed Perl Documentation					    Bio::SeqI(3pm)

NAME
Bio::SeqI - [Developers] Abstract Interface of Sequence (with features) SYNOPSIS
# Bio::SeqI is the interface class for sequences. # If you are a newcomer to bioperl, you should # start with Bio::Seq documentation. This # documentation is mainly for developers using # Bioperl. # Bio::SeqI implements Bio::PrimarySeqI $seq = $seqobj->seq(); # actual sequence as a string $seqstr = $seqobj->subseq(10,50); # Bio::SeqI has annotationcollections $ann = $seqobj->annotation(); # annotation object # Bio::SeqI has sequence features # features must implement Bio::SeqFeatureI @features = $seqobj->get_SeqFeatures(); # just top level @features = $seqobj->get_all_SeqFeatures(); # descend into sub features DESCRIPTION
Bio::SeqI is the abstract interface of annotated Sequences. These methods are those which you can be guarenteed to get for any Bio::SeqI - for most users of the package the documentation (and methods) in this class are not at useful - this is a developers only class which defines what methods have to be implmented by other Perl objects to comply to the Bio::SeqI interface. Go "perldoc Bio::Seq" or "man Bio::Seq" for more information. There aren't many here, because too many complicated functions here prevent implementations which are just wrappers around a database or similar delayed mechanisms. Most of the clever stuff happens inside the SeqFeatureI system. A good reference implementation is Bio::Seq which is a pure perl implementation of this class with a lot of extra pieces for extra manipulation. However, if you want to be able to use any sequence object in your analysis, if you can do it just using these methods, then you know you will be future proof and compatible with other implementations of Seq. 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 one of 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 - Ewan Birney Email birney@ebi.ac.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ get_SeqFeatures Title : get_SeqFeatures Usage : my @feats = $seq->get_SeqFeatures(); Function: retrieve just the toplevel sequence features attached to this seq Returns : array of Bio::SeqFeatureI objects Args : none This method comes through extension of Bio::FeatureHolderI. See Bio::FeatureHolderI and Bio::SeqFeatureI for more information. get_all_SeqFeatures Title : get_all_SeqFeatures Usage : @features = $annseq->get_all_SeqFeatures() Function: returns all SeqFeatures, included sub SeqFeatures Returns : an array of Bio::SeqFeatureI objects Args : none This method comes through extension of Bio::FeatureHolderI. See Bio::FeatureHolderI and Bio::SeqFeatureI for more information. feature_count Title : feature_count Usage : $seq->feature_count() Function: Return the number of SeqFeatures attached to a sequence Returns : integer representing the number of SeqFeatures Args : none This method comes through extension of Bio::FeatureHolderI. See Bio::FeatureHolderI for more information. seq Title : seq Usage : my $string = $seq->seq(); Function: Retrieves the sequence string for the sequence object Returns : string Args : none write_GFF Title : write_GFF Usage : $seq->write_GFF(*FILEHANDLE); Function: Convience method to write out all the sequence features in GFF format to the provided filehandle (STDOUT by default) Returns : none Args : [optional] filehandle to write to (default is STDOUT) annotation Title : annotation Usage : $obj->annotation($seq_obj) Function: retrieve the attached annotation object Returns : Bio::AnnotationCollectionI or none; See Bio::AnnotationCollectionI and Bio::Annotation::Collection for more information. This method comes through extension from Bio::AnnotatableI. species Title : species Usage : Function: Gets or sets the species Example : $species = $self->species(); Returns : Bio::Species object Args : Bio::Species object or none; See Bio::Species for more information primary_seq Title : primary_seq Usage : $obj->primary_seq($newval) Function: Retrieve the underlying Bio::PrimarySeqI object if available. This is in the event one has a sequence with lots of features but want to be able to narrow the object to just one with the basics of a sequence (no features or annotations). Returns : Bio::PrimarySeqI Args : Bio::PrimarySeqI or none; See Bio::PrimarySeqI for more information perl v5.14.2 2012-03-02 Bio::SeqI(3pm)
All times are GMT -4. The time now is 03:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy