Skip to content

Commit

Permalink
Initial commit get_random_integers
Browse files Browse the repository at this point in the history
Script to give a specified number of random integers
  • Loading branch information
Chase W. Nelson authored and Chase W. Nelson committed Nov 14, 2017
1 parent 648e061 commit 8a42961
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Perl scripts providing **C**omputational **H**elp for the **A**nalysis of **Seq*
* **[calculate\_p\_distance.pl](#calculate-p-distance)**. You want to calculate a *p*-distance between two nucleotide sequences.
* **[extract\_fasta\_by\_sites.pl](#extract-fasta-by-sites)**. You want to create separate FASTA files for segments (e.g., each of the genes) in an aligned sequence file.
* **[gb2gtf.pl](#gb-to-gtf)**. You want to create a <a target="_blank" href="http://mblab.wustl.edu/GTF22.html">GTF</a> file from a GenBank file, compatible with SNPGenie input.
* **[get\_random\_integers.pl](#get-random-integers)**. You want to get a certain number of random integer values in a range.
* **[gff2gtf.pl](#gff-to-gtf)**. You want to convert a GFF file to a simpler <a target="_blank" href="http://mblab.wustl.edu/GTF22.html">GTF</a> file, compatible with SNPGenie input.
* **[split\_fasta.pl](#split-fasta)**. You have a FASTA file, and want to create an individual FASTA file for each sequence inside.
* **[store\_fasta\_by\_ID.pl](#store-fasta-by-ID)**. You want to create a new FASTA file containing only a certain subset of another FASTA.
Expand Down Expand Up @@ -63,6 +64,10 @@ If a script isn't working, try working through the following checklist:

gb2gtf.pl <my_genbank_file.gbk>
* <a name="get-random-integers"></a>**get\_random\_integers.pl**. You want to get a certain number of random integer values in a range. At the command line, provide this script with three arguments: (1) number of random integer values wanted; (2) bottom of range (inclusive); (3) top of range (inclusive). Returns the specified number of random integers in the desired range. Here's an example to return 10 values in the range [3,999]:

get_random_integers.pl 10 3 999
* <a name="gff-to-gtf"></a>**gff2gtf.pl**. (*Helpful for preparing **<a target="_blank" href="https://github.com/chasewnelson/snpgenie">SNPGenie</a>** input!*) You want to convert a GFF file to a simpler <a target="_blank" href="http://mblab.wustl.edu/GTF22.html">GTF</a> file, compatible with SNPGenie input. At the command line, provide this script with one argument: a General Feature Format (.gff) file. It will extract the coding element annotations to produce a Gene Transfer Format (.gtf) file ready for SNPGenie, with "gene_id" annotations identified using the GFF "ID" tag. Not working, or need a different tag? Let us know, and we'll improve it! Here's an example:

gff2gtf.pl <my_gff_file.gff>
Expand Down
48 changes: 48 additions & 0 deletions get_random_integers.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /usr/bin/perl

# Takes in as arguments:
# [0] number of random integer values wanted;
# [1] bottom of range;
# [2] top of range
# OUTPUTS: specified number of random integers in range.

#########################################################################################
# EXAMPLE CALL:
#########################################################################################
# get_random_integers.pl 10 3 999
#########################################################################################

# Copyright (C) 2017 Chase W. Nelson
# AUTHOR: Chase W. Nelson
# CONTACT1: [email protected]
# AFFILIATION: Sackler Institute for Comparative Genomics, American Museum of Natural History, New York, NY 10024, USA

# ACKNOWLEDGMENTS: written by C.W.N. with support from a Gerstner Scholars Fellowship from
# the Gerstner Family Foundation at the American Museum of Natural History, New York.

my $length = $ARGV[0] or die "\nProvide a first argument, the number of numbers\n\n";
my $start_range = $ARGV[1] or die "\nProvide a second argument, the beginning of range\n\n";
my $stop_range = $ARGV[2] or die "\nProvide a third argument, the end of range\n\n";

my @numbers;

for (my $i = $start_range; $i <= $stop_range; $i++) {
push @numbers, $i;
}

#$number_to_add = $numbers[rand @numbers];

#print "\n\nMy numbers are: @numbers\n\n";

my @selection;

for (my $i = 0; $i < $length; $i++) {
$number_to_add = $numbers[rand @numbers];
push @selection, $number_to_add;
}

#print "\n\nMy random numbers are: @selection\n\n";

foreach (@selection) {
print "$_\n";
}

0 comments on commit 8a42961

Please sign in to comment.