Sponsored Content
Full Discussion: Help with a bash loop script
Top Forums UNIX for Beginners Questions & Answers Help with a bash loop script Post 303037350 by dre on Tuesday 30th of July 2019 09:34:25 AM
Old 07-30-2019
Help with a bash loop script

Create a single bash script that does the following:
a. Print out the number of occurrences for each motif that is found in the bacterial genome and output to a file called motif_count.txt
b. Create a fasta file for each motif (so 3 in total) which contains all of the genes and their corresponding sequences that have that motif. Each file should be named after the motif (ie ATG.txt) and outputted to a new directory called motifs

motif file is a txt file with these motifs : ATG, GGGGG, ATTTT
the bacterial genome file is fasta file with the following lines
Code:
 >gene1
GAAACTCGGTGTTGGCTTACCGGTCATTCCGAGCGTCATTTGGTTTTCGCGTCGTGGCGAAATGTGGTTCTACTACTCGTGGTGTATGCACTATTTATCCGGAATGTTCAGAGCGAGTAGACAATGGGTGCTCCACAATTGTGGCGGTCCCTAAGGGACTCACATATAGTGAGACACGCGTGAAATTCTGCTCACCACGTCCGAATCCGACAAATCATCTACTTCGACGGTA
>gene2
CGGAGATAAAGGACCCATACTGTACGACATTGTATTGCTCACCATGGTCAATCTTTGCGAGTTGTTGCAGCTCGCAGCTTCGTTCTGTCAATATAGCTTAGATACTGAGAAGAAGTTGCAGAGAAAGTCGCA

Moderator's Comments:
Mod Comment edit by bakunin: please use CODE-tags to let data, code and terminal output stand out. Thank you.

Last edited by bakunin; 07-30-2019 at 10:48 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

loop does not execute in bash script?

I have a very basic bash shell script, which has many "while... done; for .... done" loop clauses, like the following ~~ #!/bin/bash while blablalba; do .... done < /tmp/file for line in `cat blablabla`; do grep $line /tmp/raw ; done > /tmp/1; while blablalba2; do .... done <... (2 Replies)
Discussion started by: fedora
2 Replies

2. Shell Programming and Scripting

error in bash script 'if' loop

SEND_MESSAGE=test echo $SEND_MESSAGE if then echo `date` > update_dt_ccaps.lst echo "The file transfer failed" >> update_dt_ccaps.lst SEND_MESSAGE=false fi The above code is showing error in bash shell as : ./test: line 5: [: test: integer expression expected ... (2 Replies)
Discussion started by: DILEEP410
2 Replies

3. Shell Programming and Scripting

Whitespace in filenames in for loop in bash script

I'm trying to search all .odt files in a directory for a string in the text of the file. I've found a bash script that works, except that it can't handle whitespace in the filenames. #!/bin/bash if ; then echo "Usage: searchodt searchterm" exit 1 fi for file in $(ls *.odt); do ... (4 Replies)
Discussion started by: triplemaya
4 Replies

4. Shell Programming and Scripting

Getting error on for loop - bash script

Hi, I am working on bash script after a long time. I am getting error near done statement while running a for loop snippet. The error says "Syntax error near unexpcted token 'done'" please suggest what could be wrong. here is the snippet elements=${#option_arr} //an array of values... (1 Reply)
Discussion started by: arundhati_s
1 Replies

5. Shell Programming and Scripting

Expect script called in loop from Bash Script

Having issues with an expect script. I've been scripting bash, python, etc... for a couple years now, but just started to try and use Expect. Trying to create a script that takes in some arguments, and then for now, just runs a pwd command(for testing, final will be command I pass). Here is... (0 Replies)
Discussion started by: cbo0485
0 Replies

6. Shell Programming and Scripting

Bash script - loop question

Hi Folks, I have a loop that goes through an array and the output is funky. sample: array=( 19.239.211.30 ) for i in "${array}" do echo $i iperf -c $i -P 10 -x CSV -f b -t 50 | awk 'END{print '$i',$6}' >> $file done Output: 19.239.211.30 19.2390.2110.3 8746886 seems that when... (2 Replies)
Discussion started by: nitrohuffer2001
2 Replies

7. Shell Programming and Scripting

While loop with input in a bash script

I have the following while loop that I put in a script, demo.sh: while read rna; do aawork=$(echo "${rna}" | sed -n -e 's/\(...\)\1 /gp' | sed -f rna.sed) echo "$aawork" | sed 's/ //g' echo "$aawork" | tr ' ' '\012' | sort | sed '/^$/d' | uniq -c | sed 's/*\(*\) \(.*\)/\2: \... (3 Replies)
Discussion started by: faizlo
3 Replies

8. Shell Programming and Scripting

Loop through multiple files in bash script

Hi Everybody, I'm a newbie to shell scripting, and I'd appreciate some help. I have a bunch of .txt files that have some unwanted content. I want to remove lines 1-3 and 1028-1098. #!/bin/bash for '*.txt' in <path to folder> do sed '1,3 d' "$f"; sed '1028,1098 d' "$f"; done I... (2 Replies)
Discussion started by: BabyNuke
2 Replies

9. Shell Programming and Scripting

How to use grep in a loop using a bash script?

Dear all, Please help with the following. I have a file, let's call it data.txt, that has 3 columns and approx 700,000 lines, and looks like this: rs1234 A C rs1236 T G rs2345 G T Please use code tags as required by forum rules! I have a second file, called reference.txt,... (1 Reply)
Discussion started by: aberg
1 Replies

10. UNIX for Beginners Questions & Answers

Help with date in bash script for loop from YYYYMMDDHHMM

Hi everyone I need some help I want to create an script which does some processing it takes the two arguments 201901010000 and 201901020200 - so YYYMMDDHHMM I want to split processing into hours from start until end, I dont get why this works but when I add to a future variable... (1 Reply)
Discussion started by: kl1ngac1k
1 Replies
Bio::Map::Microsatellite(3pm)				User Contributed Perl Documentation			     Bio::Map::Microsatellite(3pm)

NAME
Bio::Map::Microsatellite - An object representing a Microsatellite marker. SYNOPSIS
$o_usat = Bio::Map::Microsatellite->new (-name=>'Chad Super Marker 2', -sequence => 'gctgactgatcatatatatatatatatatatatatatatatcgcgatcgtga', -motif => 'at', -repeats => 15, -repeat_start_position => 11 ); $sequence_before_usat = $o_usat->get_leading_flank(); $sequence_after_usat = $o_usat->get_trailing_flank(); DESCRIPTION
This object handles the notion of an Microsatellite. This microsatellite can be placed on a (linear) Map or used on its own. If this Microsatellites will be used in a mapping context (it doesn't have to, you know) it can have multiple positions in a map. For information about a Microsatellite's position in a map one must query the associate PositionI object which is accessible through the position() method. 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: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Chad Matsalla Email bioinformatics1@dieselwurks.com CONTRIBUTORS
Heikki Lehvaslaiho heikki-at-bioperl-dot-org Lincoln Stein lstein@cshl.org Jason Stajich jason@bioperl.org Sendu Bala bix@sendu.me.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : $o_usat = Function: Builds a new Bio::Map::Microsatellite object Returns : Bio::Map::Microsatellite Args : -name => name of this microsatellite (optional, string, default 'Unknown microsatellite') -positions => position(s) for this marker in maps[optional], An array reference of tuples (array refs themselves) Each tuple conatins a Bio::Map::MapI-inherited object and a Bio::Map::PositionI-inherited obj, no default) -sequence => the sequence of this microsatellite (optional, scalar, no default) -motif => the repeat motif of this microsatellite (optional, scalar, no default) -repeats => the number of motif repeats for this microsatellite (optional, scalar, no default) -repeat_start_position => the starting position of the microsatellite in this sequence. The first base of the sequence is position "1". (optional, scalar, no default) Note : Creating a Bio::Map::Microsatellite object with no position might be useful for microsatellite people wanting to embrace and extend this module. <raising hand> Me! Me! Me! - using repeat_start_position will trigger a mechinism to calculate a value for repeat_end_position. motif Title : motif Usage : $o_usat->motif($new_motif); my $motif = $o_usat->motif(); Function: Get/Set the repeat motif for this Microsatellite. Returns : A scalar representing the current repeat motif of this Microsatellite. Args : none to get, OR string to set sequence Title : sequence Usage : $o_usat->sequence($new_sequence); my $sequence = $o_usat->sequence(); Function: Get/Set the sequence for this Microsatellite. Returns : A scalar representing the current sequence of this Microsatellite. Args : none to get, OR string to set repeats Title : repeats Usage : $o_usat->repeats($new_repeats); my $repeats = $o_usat->repeats() Function: Get/Set the repeat repeats for this Microsatellite. Returns : A scalar representing the current number of repeats of this Microsatellite. Args : none to get, OR int to set repeat_start_position Title : repeat_start_position Usage : $o_usat->repeat_start_position($new_repeat_start_position); my $repeat_start_position = $o_usat->repeat_start_position(); Function: Get/Set the repeat repeat_start_position for this Microsatellite Returns : A scalar representing the repeat start position for this Microsatellite. Args : none to get, OR string to set This method will also try to set the repeat end position. This depends on having information for the motif and the number of repeats. If you want to use methods like get_trailing_flank or get_leading flank, be careful to include the right information. repeat_end_position Title : repeat_end_position Usage : $o_usat->repeat_end_position("set"); $o_usat->repeat_end_position($value); $current_repeat_end_position = $o_usat->repeat_end_position(); Function: Get/set the end position of the repeat in this sequence. Returns : A scalar representing the base index of the end of the repeat in this Microsatellite. The first base in the sequence is base 1. Args : A scalar representing a value, the string "set", or no argument (see Notes). Notes : If you do not provide an argument to this method, the current end position of the repeat in this Microsatellite will be returned (a scalar). If you provide the string "set" to this method it will set the end position based on the start position, the length of the motif, and the number of repeats. If you specify a value the current end position of the repeat will be set to that value. This is a really bad idea. Don't do it. equals Title : equals Usage : if ($mappable->equals($mapable2)) {...} Function: Test if a position is equal to another position Returns : boolean Args : Bio::Map::MappableI less_than Title : less_than Usage : if ($mappable->less_than($m2)) {...} Function: Tests if a position is less than another position Returns : boolean Args : Bio::Map::MappableI greater_than Title : greater_than Usage : if ($mappable->greater_than($m2)) {...} Function: Tests if position is greater than another position Returns : boolean Args : Bio::Map::MappableI get_leading_flank Title : get_leading_flank Usage : $leading_sequence = $o_usat->get_leading_flank(); Returns : A scalar representing the sequence before the repeats in this Microsatellite. Args : none get_trailing_flank Title : get_trailing_flank Usage : $trailing_flank = $o_usat->get_trailing_flank(); Returns : A scalar representing the sequence after the repeats in this Microsatellite. Args : none perl v5.14.2 2012-03-02 Bio::Map::Microsatellite(3pm)
All times are GMT -4. The time now is 10:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy