Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Printing into two files under difference situation Post 302861363 by Smiling Dragon on Tuesday 8th of October 2013 06:05:04 PM
Old 10-08-2013
I find myself doing this task pretty frequently from time to time, it's a bit brain-bending to think about it at first but actually is relatively straightforward:
Code:
For each gff file:
  For each line in the gff file:
    If all entries in the line are in name.txt someplace, add line to "yes" file
    Otherwise add the line to the "no" file

So:
Code:
for file in *.gff
do
  fileprefix=`echo "$file" | sed 's/\.gff$//'`
  cat ${file} | while read line
  do
    include="yes"
    for entry in $line
    do
      grep "$entry" name.txt > /dev/null || include=""
    done
    if [ -n "$include" ]
    then
      echo "${line}" >> "${fileprefix}_yes.gff"
    else
      echo "${line}" >> "${fileprefix}_no.gff"
    fi
  done
done

Not tested but should be at least pretty close.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A Challenging situation for the MODERATORS

Well, I hope this way you will respond to my inquiries. I have 4 unix servers,with static ips (though i dont think this is an issue)....i can telnet and rlogin from one to the other....if i FTP from on et othe other and try to execute : cd /user return /user : no such file or... (1 Reply)
Discussion started by: BAM
1 Replies

2. UNIX for Advanced & Expert Users

current situation

hello..what is the current situation or lastest version of UNIX?? Is there any where i can read more about it?? (2 Replies)
Discussion started by: joanne6298
2 Replies

3. Shell Programming and Scripting

sed situation

Hi, I'm looking for someone who can think in sed. Basically, I need the trailing characters on every line in a file to be deleted. These characters are all in capitals, and always follow a number, but they often vary in number For instance, on the line: 2006_10_9_p20_TALK I'd want to... (4 Replies)
Discussion started by: Laurel Maury
4 Replies

4. Programming

strange situation in file

Hi All, I am writing some data's into a file from C++ program. The files which i am writing is of fixed length . say 232 in length per line. I am writing as . my c code is as ... (0 Replies)
Discussion started by: arunkumar_mca
0 Replies

5. UNIX for Dummies Questions & Answers

help : crisis situation !!

Hi I had deleted important files from my company server :( the server is HPUX and i don't know how to undo rm command or how to restore the files .. iam appreciate for any help Thanx ... (5 Replies)
Discussion started by: Eisa
5 Replies

6. Shell Programming and Scripting

Comparing Columns and printing the difference from a particular file

Gurus, I have one file which is having multiple columns and also this file is not always contain the exact columns; sometimes it contains 5 columns or 12 columns. Now, I need to find the difference from that particular file. Here is the sample file: param1 | 10 | 20 | 30 | param2 | 10 |... (6 Replies)
Discussion started by: buzzusa
6 Replies

7. Shell Programming and Scripting

Columns comparision of two large size files and printing the difference

Hi Experts, My requirement is to compare the second field/column in two files, if the second column is same in both the files then compare the first field. If the first is not matching then print the first and second fields of both the files. first file (a .txt) < 1210018971FF0000,... (6 Replies)
Discussion started by: krao
6 Replies

8. Shell Programming and Scripting

Cat files situation

Hello, I am PhD student (Biomedical sciences) and very new to Linux. I need some help with the following task : I have files in the following format for their names : An_A1_nnn_R1.txt; An_A1_nnm_R1.txt; An_A1_nnoo_R1.txt An_A2_nnn_R1.txt; An_A2_nnm_R1.txt; An_A2_nno_R1.txt ... (8 Replies)
Discussion started by: Julio Finalet
8 Replies

9. Shell Programming and Scripting

Compare line and printing difference

Hi, I want to compare two files and print out their differences e.g: t1.txt a,b,c,d t2.txt a,b,c,d,e,f Output e,f Currently I do this long about way tr ',' '\n' <t1.txt >t1.tmp tr ',' '\n' <t2.txt >t2.tmp diff t1.tmp t2.tmp > t12.tmp I have to this comparison for 100 files, so... (3 Replies)
Discussion started by: wahi80
3 Replies

10. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies
Bio::FeatureIO::gff(3pm)				User Contributed Perl Documentation				  Bio::FeatureIO::gff(3pm)

NAME
Bio::FeatureIO::gff - read/write GFF feature files SYNOPSIS
my $feature; #get a Bio::SeqFeature::Annotated somehow my $featureOut = Bio::FeatureIO->new( -format => 'gff', -version => 3, -fh => *STDOUT, -validate_terms => 1, #boolean. validate ontology terms online? default 0 (false). ); $featureOut->write_feature($feature); DESCRIPTION
Currently implemented: version read? write? ------------------------------ GFF 1 N N GFF 2 N N GFF 2.5 (GTF) N Y GFF 3 Y Y 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 list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_list - 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 of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR
Allen Day, <allenday@ucla.edu> CONTRIBUTORS
Steffen Grossmann, <grossman@molgen.mpg.de> Scott Cain, <scain@cpan.org> Rob Edwards <rob@salmonella.org> APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ next_feature() Usage : my $feature = $featureio->next_feature(); Function: reads a feature record from a GFF stream and returns it as an object. Returns : a Bio::SeqFeature::Annotated object Args : N/A next_feature_group Title : next_feature_group Usage : @feature_group = $stream->next_feature_group Function: Reads the next feature_group from $stream and returns it. Feature groups in GFF3 files are separated by '###' directives. The features in a group might form a hierarchical structure. The complete hierarchy of features is returned, i.e. the returned array represents only the top-level features. Lower-level features can be accessed using the 'get_SeqFeatures' method recursively. Example : # getting the complete hierarchy of features in a GFF3 file my @toplevel_features; while (my @fg = $stream->next_feature_group) { push(@toplevel_features, @fg); } Returns : an array of Bio::SeqFeature::Annotated objects Args : none next_seq() access the FASTA section (if any) at the end of the GFF stream. note that this method will return undef if not all features in the stream have been handled write_feature() Usage : $featureio->write_feature( Bio::SeqFeature::Annotated->new(...) ); Function: writes a feature in GFF format. the GFF version used is governed by the '-version' argument passed to Bio::FeatureIO->new(), and defaults to GFF version 3. Returns : ###FIXME Args : a Bio::SeqFeature::Annotated object. ACCESSORS
fasta_mode() Usage : $obj->fasta_mode($newval) Function: Example : Returns : value of fasta_mode (a scalar) Args : on set, new value (a scalar or undef, optional) Side effect when setting: rewind the file handle a little bit to get the last carriage return that was swallowed when the previous line was processed. seqio() Usage : $obj->seqio($newval) Function: holds a Bio::SeqIO instance for handling the GFF3 ##FASTA section. Returns : value of seqio (a scalar) Args : on set, new value (a scalar or undef, optional) sequence_region() Usage : Function: ###FIXME Returns : Args : so() Usage : $obj->so($newval) Function: holds a Sequence Ontology instance Returns : value of so (a scalar) Args : on set, new value (a scalar or undef, optional) validate() Usage : $obj->validate($newval) Function: true if encountered ontology terms in next_feature() mode should be validated. Returns : value of validate (a scalar) Args : on set, new value (a scalar or undef, optional) version() Usage : $obj->version($newval) Function: version of GFF to read/write. valid values are 1, 2, 2.5, and 3. Returns : value of version (a scalar) Args : on set, new value (a scalar or undef, optional) INTERNAL METHODS
_buffer_feature() Usage : Function: ###FIXME Returns : Args : ignore_seq_region Set this flag to keep FeatureIO from returning a feature for a ##sequence-region directive _handle_directive() this method is called for lines beginning with '##'. _handle_feature() this method is called for each line not beginning with '#'. it parses the line and returns a Bio::SeqFeature::Annotated object. _handle_non_reserved_tag() Usage : $self->_handle_non_reserved_tag($feature,$tag,$value) Function: Deal with non-reserved word tags in the ninth column Returns : An updated Bio::SeqFeature::Annotated object Args : A Bio::SeqFeature::Annotated and a tag/value pair Note that this method can be overridden in a subclass to provide special handling of non-reserved word tags. organims Gets/sets the organims from the organism directive _write_feature_1() write a feature in GFF v1 format. currently not implemented. _write_feature_2() write a feature in GFF v2 format. currently not implemented. _write_feature_25() write a feature in GFF v2.5 (aka GTF) format. _write_feature_3() write a feature in GFF v3 format. perl v5.14.2 2012-03-02 Bio::FeatureIO::gff(3pm)
All times are GMT -4. The time now is 01:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy