Sponsored Content
Top Forums Shell Programming and Scripting reading information from a table and apply a command on multiple files Post 302708825 by @man on Tuesday 2nd of October 2012 09:38:53 AM
Old 10-02-2012
MySQL reading information from a table and apply a command on multiple files

Hey gyuz,

I wanna calculate the number of mapped reads of a bam file in a region of interest. I used this code to do so :

Code:
samtools view input.bam chrname:region1 > region1.txt

This will store all the reads from given bam file within the region of interest in region1.txt

Now I have several bam files and several regions for each which are different. (regions are not the same in all bam files)

I prepared a list of them like below:

bam1 region1
bam1 region2
bam1 region3
bam2 region4
bam2 region4
bam3 region5

I want the script to read from the table and apply the function on proper bam file and regions and report the output for each region in a single file. region1.txt, region2.txt, region3.txt,.....

If you can help me with this you saved my time so much!!

Thanks in advance.

Last edited by @man; 10-02-2012 at 12:44 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Apply `chmod` for multiple files through FTP

Hi all, Can you please help me in this aspect. I devoloped a FTP script to copy a directory to remote server. Now i got stuck-up in changing the file permissions for all the files in directory. I tried to change the permissions of single file and I did it but failed in changing... (3 Replies)
Discussion started by: Chanakya.m
3 Replies

2. Shell Programming and Scripting

How to Pull out multiple files from DB table and redirect all those files to a differetn directory?

Hi everyone!! I have a database table, which has file_name as one of its fields. Example: File_ID File_Name Directory Size 0001 UNO_1232 /apps/opt 234 0002 UNO_1234 /apps/opt 788 0003 UNO_1235 /apps/opt 897 0004 UNO_1236 /apps/opt 568 I have to... (3 Replies)
Discussion started by: ss3944
3 Replies

3. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

4. Shell Programming and Scripting

apply record separator to multiple files within a directory using awk

Hi, I have a bunch of records within a directory where each one has this form: (example file1) 1 2 50 90 80 90 43512 98 0909 79869 -9 7878 33222 8787 9090 89898 7878 8989 7878 6767 89 89 78676 9898 000 7878 5656 5454 5454 and i want for all of these files to be... (3 Replies)
Discussion started by: amarn
3 Replies

5. Shell Programming and Scripting

extracting information from multiple files

Hello there, I am trying to extract (string) information ( a list words) from 4 files and then put the results into 1 file. Currently I am doing this using grep -f list.txt file1 . and repeat the process for the other 3 files. The reasons i am doing that (a) I do know how to code (b) each file... (4 Replies)
Discussion started by: houkto
4 Replies

6. UNIX for Dummies Questions & Answers

Reading Table name from a list of files in a Directory

Hi , I have searched through the forum but not able to find out any help :( i have a directory having lot of files which contains sql statemtns eg : file 1 contains select from table_name1 where ..................... select from table_name2 where .......... select from ... (3 Replies)
Discussion started by: Trendz
3 Replies

7. Shell Programming and Scripting

search information in multiple files and save in new files

hi everyone, im stuck in here with shell :) can you help me?? i have a directory with alot files (genbank files ... all ended in .gbk ) more than 1000 for sure ... and i want to read each one of them and search for some information and if i found the right one i save in new file with new... (6 Replies)
Discussion started by: andreia
6 Replies

8. UNIX for Dummies Questions & Answers

Load multiple files into a table

Hi, I need to load data from two files to a single table. My requirement is that I get two files in which a few column data are manadatory. These files are identified based on the file name. For example, I have two files ABCFile and BCDFile. ABCFile has mandatory data in column 3 and 4... (0 Replies)
Discussion started by: reshma15193
0 Replies

9. Shell Programming and Scripting

Apply command to all files in folder

Hi all! I have this command grep -E '^\To: |^\Date: |^\Subject: ' fileA.txt > fileA_1.txt && grep -v '^\To: |^\Date: |^\Subject: ' fileA.txt >> fileA_1.txt && rm fileA.txt && sed -i -e 's/\(Date: \|Subject: \|To: \)//g' fileA_1.txtHow do I apply it to all the files in the folder (each file has a... (7 Replies)
Discussion started by: guilliber
7 Replies

10. UNIX for Beginners Questions & Answers

How to apply the update statement in multiple servers on multiple dbs at a time .?

Hi , Can any please help the below requirement on all multiple servers and multiple dbs. update configuration set value='yes' ;1) the above statement apply on 31 Databases at a time on different Ip address eg : 10.104.1.12 (unix ip address ) the above ip box contains 4 db's eg : db... (2 Replies)
Discussion started by: venkat918
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 11:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy