Entering edit mode
12 months ago
CourtneyGoRawr
▴
10
Hi, this is my first time posting so sorry ahead of time if I leave something out, I am writing a code to end up joining information out of two files. Right now I am trying to split the first file so I can get the IDs in the first column and the information in the 9th column. My code at the moment will only print out 1 of the entries on command and nothing is printing to my file. I can get it to print other than the first entry but it still only prints one.
Here's what I have:
#!/usr/bin/perl
if ($ARGV != 1)
{
print "FinalProject.pl input01 output.\n";
exit;
}
print "it is running...\n";
#variables
my $input01 = $ARGV[0];
my $output = $ARGV[1];
#my $file01 = "male.sp4";
#my $file02 = 'ps.parse';
my @PeptideValue = (); #to store value from column 9
my @ID = (); #to store all protein IDs
my @Final = (); #to save all into
#check IDs in both files against each other
#if ID is present in both files "ER" is desingated, if not "-"
open my $infile, "<", "male.sp4" or die "Can't read from $infile: $!";
open my $outfile, ">", "OUT.txt" or die "Can't create $outfile: $!";
my (@PeptideValue, @ID);
while (<$infile>)
{
my @Values = split(/\s+/), $infile;
push @ID, $Values[0];
push @PeptideValue, $Values[9];
}
open (OUT, ">@Values");
print OUT (@ID);
close (OUT);
open (OUT, ">@Values");
print OUT (@PeptideValue);
close (OUT);
print "$ID[]\n";
print "$PeptideValue[]\n";
#retrieve values in column 9
#open (File01, $file01);
#$file01 = <File01>;
close $infile;
my first file looks like:
PisGene40001 0.142 21 0.193 21 0.548 4 0.256 0.227 N 0.450 SignalP-noTM
PisGene40002 0.135 14 0.126 14 0.153 12 0.121 0.124 N 0.450 SignalP-noTM
PisGene40003 0.134 52 0.158 17 0.357 6 0.226 0.185 N 0.500 SignalP-TM
PisGene40004 0.478 30 0.642 30 0.984 17 0.879 0.770 Y 0.450 SignalP-noTM
PisGene40005 0.115 17 0.109 1 0.116 1 0.000 0.050 N 0.450 SignalP-noTM
my output looks like:
PisGene40001
N
Why is it only printing the first one? Thanks in advance for help!
this doesn't look right in a couple ways. can you change it to:
when I changed that it printed out "FinalProject.pl input01 output."
ok this script has a few more problems. kind of looks like you are not entirely understanding filehandles. is this a homework assignment or your day job?
it's a homework assignment
have a look at join https://shapeshed.com/unix-join/