Sponsored Content
Top Forums Shell Programming and Scripting Parse tab delimited file, check condition and delete row Post 302702575 by rdrtx1 on Tuesday 18th of September 2012 02:01:34 PM
Old 09-18-2012
Code:
 
NR == 1 { print "#" $0; }         # print record number 1 preceeded with "#"
NR > 1 {                          # for record number > 1
  l1c=l2c=0;                      # set counters
  for (i=5; i<=NF; i++) {         # for fields 5 and greater
    if ($3 == $(i)) l1c++;        # if field matches field 3 increment counter 1
    if ($4 == $(i)) l2c++;        # if field matches field 4 increment counter 2
  }
  if (l1c>1 && l2c>1) print $0;   # if counters are both > 1 print line;
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check whether a given file is in ASCII format and data is tab-delimited

Hi All, Please help me out with a script which checks whether a given file say abc.txt is in ASCII format and data is tab-delimited. If the condition doesn't satisfy then it should generate error code "100" for file not in ASCII format and "105" if it is not in tab-delimited format. If the... (9 Replies)
Discussion started by: Mandab
9 Replies

2. Shell Programming and Scripting

Delete parts of a string of character in one given column of a tab delimited file

I would like to remove characters from column 7 so that from an input file looking like this: >HWI-EAS422_12:4:1:69:89 GGTTTAAATATTGCACAAAAGGTATAGAGCGT U0 1 0 0 ref_chr8.fa 6527777 F DD I get something like that in an output file: ... (13 Replies)
Discussion started by: matlavmac
13 Replies

3. Shell Programming and Scripting

Delete first column in tab-delimited text-file

I have a large text-file with tab-delimited genetic data that looks like: KSC112 KSC234 0 0 1 1 A G C T I simply wan to delete the first column, but since the file has 600 000 columns, it is not possible with awk (seems to be limited at 32k columns). Does anyone have an idea how to do this? (2 Replies)
Discussion started by: andmal
2 Replies

4. UNIX for Dummies Questions & Answers

How do you delete cells from a space delimited text file given row and column number?

How do you delete cells from a space delimited text file given row and column number? Letś say the row number is r and the column number is c. Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies

5. UNIX for Dummies Questions & Answers

Delete header row and reformat from tab delimited to fixed width

Hello gurus, I have a file in a tab delimited format and a header row. I need a code to delete the header in the file, and convert the file to a fixed width format, with all the columns aligned. Below is a sample of the file:... (4 Replies)
Discussion started by: chumsky
4 Replies

6. Shell Programming and Scripting

Delete an entire column from a tab delimited file

Hi, Can anyone please tell me about how we can delete an entire column from a tab delimited file? Mu input_file.txt looks like this: And I want the output as: I used the below code nawk -v d="1" 'BEGIN{FS=OFS="\t"}{$d=""}{print}' input_file.txtBut in the output, the first column is... (5 Replies)
Discussion started by: sampoorna
5 Replies

7. Shell Programming and Scripting

Delete and insert columns in a tab delimited file

Hi all , I have a file having 12 columns tab delimited . I need to read this file and remove the column 3 and column 4 and insert a word in column 3 as "AVIALABLE " Is there a way to do this . I am trying like below Thanks DJ cat $FILENAME|awk -F"\t" '{ print $1 "\t... (3 Replies)
Discussion started by: Hypesslearner
3 Replies

8. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies

9. UNIX for Beginners Questions & Answers

awk to parse current and next row in tab-delimited file

Hi there, I would like to use awk to reformat a tab-delimited file containing three columns as follows: Data file: sample 1 173 sample 269 530 sample 687 733 sample 1699 1779 Desired output file: sample 174..265, 531..686, 734..1698 I need the value... (5 Replies)
Discussion started by: emiley
5 Replies

10. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies
Bio::Tools::Run::Samtools(3pm)				User Contributed Perl Documentation			    Bio::Tools::Run::Samtools(3pm)

NAME
Bio::Tools::Run::Samtools - a run wrapper for the samtools suite *BETA* SYNOPSIS
# convert a sam to a bam $samt = Bio::Tools::Run::Samtools( -command => 'view', -sam_input => 1, -bam_output => 1 ); $samt->run( -bam => "mysam.sam", -out => "mysam.bam" ); # sort it $samt = Bio::Tools::Run::Samtools( -command => 'sort' ); $samt->run( -bam => "mysam.bam", -pfx => "mysam.srt" ); # now create an assembly $assy = Bio::IO::Assembly->new( -file => "mysam.srt.bam", -refdb => "myref.fas" ); DESCRIPTION
This is a wrapper for running samtools, a suite of large-alignment reading and manipulation programs available at <http://samtools.sourceforge.net/>. RUNNING COMMANDS
To run a "samtools" command, construct a run factory, specifying the desired command using the "-command" argument in the factory constructor, along with options specific to that command (see "OPTIONS"): $samt = Bio::Tools::Run::Samtools->new( -command => 'view', -sam_input => 1, -bam_output => 1); To execute, use the "run()" method. Input and output files are specified in the arguments of "run()" (see "FILES"): $samt->run( -bam => "mysam.sam", -out => "mysam.bam" ); OPTIONS
"samtools" is complex, with many subprograms (commands) and command-line options and file specs for each. This module attempts to provide commands and options comprehensively. You can browse the choices like so: $samt = Bio::Tools::Run::Samtools->new( -command => 'pileup' ); # all samtools commands @all_commands = $samt->available_parameters('commands'); @all_commands = $samt->available_commands; # alias # just for pileup @pup_params = $samt->available_parameters('params'); @pup_switches = $samt->available_parameters('switches'); @pup_all_options = $samt->available_parameters(); Reasonably mnemonic names have been assigned to the single-letter command line options. These are the names returned by "available_parameters", and can be used in the factory constructor like typical BioPerl named parameters. See <http://samtools.sourceforge.net/samtools.shtml> for the gory details. FILES
When a command requires filenames, these are provided to the "run()" method, not the constructor ("new()"). To see the set of files required by a command, use "available_parameters('filespec')" or the alias "filespec()": $samt = Bio::Tools::Run::Samtools->new( -command => 'view' ); @filespec = $samt->filespec; This example returns the following array: bam >out This indicates that the bam/sam file (bam) and the output file (out) MUST be specified in the "run()" argument list: $samt->run( -bam => 'mysam.sam', -out => 'mysam.cvt' ); If files are not specified per the filespec, text sent to STDOUT and STDERR is saved and is accessible with "$bwafac-"stdout()> and "$bwafac-"stderr()>. 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_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 of the bugs and their resolution. Bug reports can be submitted via the web: http://redmine.open-bio.org/projects/bioperl/ AUTHOR - Mark A. Jensen Email maj -at- fortinbras -dot- us APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $obj = new Bio::Tools::Run::Samtools(); Function: Builds a new Bio::Tools::Run::Samtools object Returns : an instance of Bio::Tools::Run::Samtools Args : perl v5.12.3 2011-06-18 Bio::Tools::Run::Samtools(3pm)
All times are GMT -4. The time now is 03:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy