Sponsored Content
Top Forums Shell Programming and Scripting User input and run awk using the input Post 302967336 by sea on Tuesday 23rd of February 2016 01:42:52 AM
Old 02-23-2016
This:
Code:
printf "Please enter the gene(s) of interest, use a comma between multiple: "
IFS="," read -a gene
        printf "the indicated genes will now be loaded and used to calculate coverage\n"

Will not work as you expect.

In fact, you tell to only catch the first genom only, and no other.
Because you say the IFS shall be ',' which is shall be used to seperate the genoms, mainwhile, you only read 1 genom, as 'gene' will be split into as many arguments/variables as the user passes using ','.

Saying:
Replcae the IFS= part to a later procedure, when parsing the user input.
Parsing is done after reading, or if while reading, it must be a limited (say pass 3 genoms, then you mus tread 3 variables - not just one).

I'm no scientist, but afaik a genom doesnt have 'spaces' in between, so they might just seperate the genoms passed by spaces OR coma - since the IFS is removed, that doesnt matter, in fact, its even simpler to work with the passed genoms, if the users do not use ',' to seperate the list.

Only use the red parts if you insist of using coma to seperate the list, if using space its not required at all.
Code:
read genes
oIFS="$IFS"
IFS=","
for gene in $genes;do
	echo "Working with genom: $gene"
done
IFS="$oIFS"

Other than that, please make the according corrections of for loops as Don already stated.

Thank you and hope this helps
This User Gave Thanks to sea For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk user input

Using the following I'm trying to print the user's response to the prompt Y / N but I get nothing other than the contents of $1? awk '{ printf($1 " ? (Y/N)") getline myresponse < "-" system("read myresponse") if (myresponse == "Y") { print $1... (17 Replies)
Discussion started by: gefa
17 Replies

2. Shell Programming and Scripting

AWK set FILENAME via user input

I am trying to write a awk script that prompts user for input to set the FILENAME varable. I can get it set, but I think awk is not doing anything with it. this is what I have so far #!/usr/bin/nawk -f BEGIN { FILENAME = "" printf "Enter name of file to check in : " ... (2 Replies)
Discussion started by: timj123
2 Replies

3. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

4. Shell Programming and Scripting

How to take input from user or awk script?

Hi Jim, I have following script,i which i need to take dynamic value . script, nawk -v v1=grep"INT_EUR" $propertifilename | cut -d"=" -F2` -F'~' '{if (NF-1 !=v1) {print "Error in " $0 " at line number "NR" tilde count " N-1}}' $filename In the above script i want to use INT_EUR as a variable... (2 Replies)
Discussion started by: Ganesh Khandare
2 Replies

5. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

6. Shell Programming and Scripting

Awk replacing file with user input

this section of the awk code i have here takes file to work with from the user. the user specifies the file name from the command line and the file name is assigned to the variable $FLIST awk 'BEGIN { while((getline < "'${FLIST}'")>0) S FS="\n"; RS="}\n" } now, i dont want... (5 Replies)
Discussion started by: SkySmart
5 Replies

7. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

8. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

9. Programming

Keyboard User Input in awk language ?

Hi, does someone know how to make a keyboard data input in the AWK programming language ? Regards Zabo (6 Replies)
Discussion started by: Zabo
6 Replies

10. Shell Programming and Scripting

awk command to search based on 5 user input fields

Field1=”” Field2=”” Field3=”” Field4=”” Field5=”” USER INPUT UP TO 5 FIELDS awk -F , '{ if ( $3 == Field1 && $6 == Field2 && $8 == Field3 && $9 == Field4 && $10 == Field5) print $0 }' /tmp/rodney.outD INPUT FILE (Rodney.outD): ... (3 Replies)
Discussion started by: rmerrird
3 Replies
Bio::Map::GeneMap(3pm)					User Contributed Perl Documentation				    Bio::Map::GeneMap(3pm)

NAME
Bio::Map::GeneMap - A MapI implementation to represent the area around a gene SYNOPSIS
use Bio::Map::GeneMap; use Bio::Map::Gene; use Bio::Map::TranscriptionFactor; use Bio::Map::GeneRelative; # make some maps that will represent an area around a particular gene in # particular species (by default, the map represents the area in the genome # 1000bp upstream of the gene) my $map1 = Bio::Map::GeneMap->get(-gene => 'BRCA2', -species => 'human', -description => 'breast cancer 2, early onset'); my $map2 = Bio::Map::GeneMap->get(-gene => 'BRCA2', -species => 'mouse'); # model a TF that binds 500bp upstream of the BRCA2 gene in humans and # 250bp upstream of BRCA2 in mice my $rel = Bio::Map::GeneRelative->new(-description => "gene start"); my $tf = Bio::Map::TranscriptionFactor->get(-universal_name => 'tf1'); Bio::Map::Position->new(-map => $map1, -element => $tf, -start => -500, -length => 10, -relative => $rel); Bio::Map::Position->new(-map => $map2, -element => $tf, -start => -250, -length => 10, -relative => $rel); # find out all the things that map near BRCA2 in all species foreach my $map ($gene->known_maps) { foreach my $thing ($map->get_elements) { next if $thing eq $gene; foreach my $pos ($thing->get_positions($map)) { print "In species ", $map->species, ", ", $thing->universal_name, " maps at ", $pos->value, " relative to ", $pos->relative->description, " of gene ", $gene->universal_name, " "; } } } # a GeneMap isa PrimarySeq and so can have sequence associated with it $map1->seq('ATGC'); my $subseq = $map1->subseq(2,3); # TG DESCRIPTION
Model the abstract notion of the area around a gene - you don't care exactly where this area is in the genome, you just want to be able to say "something binds upstream of gene X" and "something else binds 20bp upstream of the first something" etc. It's useful for modelling transcription factor bindings sites, letting you find out which transcription factors bind near a gene of interest, or which genes are bound by a transcription factor of interest. See t/Map/Map.t for more example usage. 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 - Sendu Bala Email 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 : my $obj = Bio::Map::GeneMap->new(); Function: Builds a new Bio::Map::GeneMap object (that has placed on it a mappable element (Bio::Map::Gene) representing a gene). Returns : Bio::Map::GeneMap Args : -gene => string name of the gene this map will be for (in a form common to all species that have the gene, but unique amongst non-orthologous genes) or a Bio::Map::Gene object, REQUIRED -species => Bio::Taxon or string representing species, REQUIRED -uid => string, unique identifier for this map (must be unique amongst all gene/species combinations) -description => string, free text description of the gene -upstream => int, the number of bases the map extends before the start of the gene element (default 1000). -downstream => int, the number of bases the map extends beyond the end of the gene element (default 0). -seq => string, the sequence of the map, presumably the genomic sequence -upstream bases of the gene, including the gene, and -downstream bases of the gene get Title : get Usage : my $map = Bio::Map::GeneMap->get(); Function: Builds a new Bio::Map::GeneMap object (like new()), or gets a pre-existing one that corresponds to your arguments. Returns : Bio::Map::GeneMap Args : -gene => string name of the gene this map will be for (in a form common to all species that have the gene, but unique amongst non-orthologous genes) or a Bio::Map::Gene object, REQUIRED -species => Bio::Taxon or string representing species, REQUIRED -uid => string, unique identifier for this map (must be unique amongst all gene/species combinations) -description => string, free text description of the gene -upstream => int, the number of bases the map extends before the start of the gene element (default 1000). -downstream => int, the number of bases the map extends beyond the end of the gene element (default 0). -seq => string, the sequence of the map, presumably the genomic sequence -upstream bases of the gene, including the gene, and -downstream bases of the gene If you supply a -uid, and a map had previously been created and given that uid, that same map object will be returned. Otherwise, the combination of -gene and -species will be used to determine if the same map had previously been made. If a corresponding map hadn't previously been made, a new map object will be created and returned. unique_id Title : unique_id Usage : my $id = $map->unique_id; Function: Get/set the unique ID for this map Returns : string Args : none to get, OR string to set species Title : species Usage : my $species = $map->species; Function: Get/set Species for a map. It is not recommended to change this once set. Returns : Bio::Taxon object or string Args : none to get, OR Bio::Taxon or string to set type Title : type Usage : my $type = $map->type Function: Get Map type Returns : string 'gene' Args : none gene Title : gene Usage : my $gene = $map->gene; $map->gene(-gene => $gene); Function: Get/set the mappable element on this map that represents the gene this map is for. Once set, it is not recommended to re-set the gene to something else. Behaviour in that case is undefined. Returns : Bio::Map::Gene Args : none to get, OR to set: -gene => Bio::Map::Gene or string of the universal name (see Bio::Map::Gene docs), REQUIRED -description => string, applied to the Bio::Map::Gene -upstream => int, the number of bases the map extends before the start of the gene element (default 1000). -downstream => int, the number of bases the map extends beyond the end of the gene element (default 0). universal_name Title : universal_name Usage : my $name = $map->universal_name Function: Get/set the name of Bio::Map::Gene object associated with this map. It is not recommended to change this once set. Returns : string Args : none to get, OR string to set upstream Title : upstream Usage : my $distance = $map->upstream; $map->upstream($distance); Function: Get/set how long the map is before the start of the Bio::Map::Gene object on this map. Returns : int Args : none to get, OR int to set (the number of bases the map extends before the start of the gene) downstream Title : downstream Usage : my $distance = $map->downstream; $map->downstream($distance); Function: Get/set the nominal end of the map relative to the end of the Bio::Map::Gene object on this map. Returns : int Args : none to get, OR int to set (the number of bases the map extends beyond the end of the gene) length Title : length Usage : my $length = $map->length(); Function: Retrieves the length of the map. This is normally the length of the upstream region + length of the gene + length of the downstream region, but may be longer if positions have been placed on the map beyond the end of the nominal downstream region. Returns : int Args : none seq Title : seq Usage : $string = $obj->seq() Function: Get/set the sequence as a string of letters. When getting, If the GeneMap object didn't have sequence attached directly to it for the region requested, the map's gene's database will be asked for the sequence, and failing that, the map's gene's positions will be asked for their sequences. Areas for which no sequence could be found will be filled with Ns, unless no sequence was found anywhere, in which case undef is returned. Returns : string Args : Optionally on set the new value (a string). An optional second argument presets the alphabet (otherwise it will be guessed). subseq Title : subseq Usage : $substring = $obj->subseq(10, 40); Function: Returns the subseq from start to end, where the first base is 1 and the number is inclusive, ie 1-2 are the first two bases of the sequence. If the GeneMap object didn't have sequence attached directly to it for the region requested, the map's gene's database will be asked for the sequence, and failing that, the map's gene's positions will be asked for their sequences. Areas for which no sequence could be found will be filled with Ns, unless no sequence was found anywhere, in which case undef is returned. subseq requests that extend beyond the end of the map will throw. Returns : string Args : integer for start position AND integer for end position OR Bio::LocationI location for subseq (strand honored) OR Bio::RangeI (eg. a Bio::Map::PositionI) perl v5.14.2 2012-03-02 Bio::Map::GeneMap(3pm)
All times are GMT -4. The time now is 12:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy