-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpick_columns_into_fasta
40 lines (35 loc) · 1.28 KB
/
pick_columns_into_fasta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl
#This file is designed to pull specific columns from a spreadsheet and put them into a new file in fasta format which can be read by BLAT.
#import the Tie::File module which allows a file to be read one line at a time
use Tie::File;
use Fcntl;
use strict;
use warnings;
#define variables (an array and then all columns in the spreadsheet)
my (@primers,$primers);
my $Gene;
my $Exon;
my $Chromosomes;
my $Primername;
my $Newname;
my $Primerseq;
my $PCRcond;
my $Modification;
my $Ampsize;
my $Stock;
my $Tray;
my $Gridref;
my $SNPCheck;
my $datesnpcheck;
my $SNPdbbuild;
my $SNP;
# use tie to take each line of the file and enter it into the array primers
tie @primers, 'Tie::File', "/home/aled/Documents/primerdb/ACTA.csv";
#specify the fasta file for the output
open (MYFILE, '>>/home/aled/Documents/primerdb/primersequences.fa');
# for each element ($primers) of the array (@primers) split it on the comma into these named elements. Then print selected columns into the file in a fasta format.
foreach $primers (@primers) {
my @s = split(/,/, $primers);
($Gene,$Exon,$Chromosomes,$Primername,$Newname,$Primerseq,$PCRcond,$Modification,$Ampsize,$Stock,$Tray,$Gridref,$SNPCheck,$datesnpcheck,$SNPdbbuild,$SNP) = @s;
print MYFILE "> $Primername \n $Primerseq \n";
} untie @primers;