Outputfile is not saving - Perl solved


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Outputfile is not saving - Perl solved
# 1  
Old 10-02-2010
Outputfile is not saving - Perl solved

Dear all
I have this perl script where it also linked R script but the outputfile (anchorresult.temp)is also disappearing after I got the R figure. Do you guys know how to preserve the file

Code:
#!/usr/bin/perl

$anchorfile=&QQQ("Anchor file (include the path):");
$anchortype=&QQQ("Anchor type (Point or Segment):");
$scale=&QQQ("Scale segment length to (mean, median, min, max or custom(eg:30) ):") if $anchortype eq "Segment";
$scale=1 if $anchortype eq "Point";
$signalfile=&QQQ("Signal file(include the path):");
$signaltype=&QQQ("Signal type (Point or Segment):");
$scopefile=&QQQ("Scope file (hg18, mm9, ce6, dm3 or custom file(include the path) ):") if $signaltype eq "Segment";
$plotRange=&QQQ("Plot range (+/- N bp, default is 2000):");
$plotRange=2000 if $plotRange eq "";
$scopefile="coords.".$scopefile if $scopefile eq "hg18" || $scopefile eq "mm9" || $scopefile eq "ce6" || $scopefile eq "dm3";

if($signaltype eq "Segment")
{
	system("./anchor.to.tag $anchorfile $signalfile $scale > anchorsignal.temp");
	system("./anchor.to.tag $anchorfile $scopefile $scale > anchorscope.temp");
	system("./anchor.map.tagscope anchorsignal.temp anchorscope.temp $scale -$plotRange $plotRange > anchormap.temp");
	system("./cutcolumn anchormap.temp 2 3 > anchorresult.temp");
}
elsif($signaltype eq "Point")
{
	system("./anchor.to.probe $anchorfile $signalfile $scale > anchorsignal.temp");
	system("./anchor.map.probe anchorsignal.temp $scale -$plotRange $plotRange > anchormap.temp");
	system("./cutcolumn anchormap.temp 1 2 > anchorresult.temp");
}
else
{
	print "Anchor type is wrong! Please choose 'Segment' or 'Point'.\n";
}

open out,">gsaRscript.temp";
print out <<END;
mydata = read.table("anchorresult.temp",sep="\\t")
attach(mydata)
pdf("gsa_result.pdf")
plot(mydata[,1],mydata[,2],ylab="Signal",xlab="Relative distance to anchor",cex=0.2,type="l",xlim=c(-$plotRange,$plotRange))
dev.off()
END
close out;

system("Rscript gsaRscript.temp");
system("rm *.temp");

sub QQQ
{
	my $question = shift @_;
	print "$question\n";
	chomp(my $answer = <STDIN>);
	return $answer;
}



---------- Post updated at 07:43 AM ---------- Previous update was at 07:34 AM ----------

sorry guys. I found the bug i forgot to put # before
Code:
system("rm *.temp");

No need of any answers. Thanx
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

2. Shell Programming and Scripting

[Solved] UNIX command in PERL

I tried to use this command in PERL code. when I run this on shell , it's working fine. grep -v "^#" /oratab | awk -F: '$1 == "'$server'" {print $2}' inside PERL $ohome = `grep -v "^#" /oratab | awk -F: '$1 == "'$server'" {print $2}'` ; but, it's not returning anything back ... what... (0 Replies)
Discussion started by: talashil
0 Replies

3. Programming

[Solved] Removing duplicates from the file and saving as new file

Dear All I have 200 data files and each files has many duplicates. I am looking for the automated awk script such that it checks and removes the duplicates from the each file and saving them as new files for all 200 files in the respective folder. For example my data looks like this.. ... (12 Replies)
Discussion started by: bala06
12 Replies

4. Shell Programming and Scripting

Problem saving return value of subroutine in perl

Hi all, I have this code #This program read the triplets from file named "data" into #an array of array. use strict; use warnings; use Data::Dumper; use Graph; use Graph::Subgraph; my @S; while (<>) { push @S, ; } print "-----TRIPLETS-------\n"; print Dumper \@S; #Make... (6 Replies)
Discussion started by: rushadrena
6 Replies

5. Shell Programming and Scripting

[Solved] Remove LaTex Tag with perl

Hi, i am trying to remove all LaTex tags (\index{text} from a big input file, using perl. My current approach which does not work is the following. perl -ne '$/=undef; s/\\index\{*?\}//g; print' < $CWD/$OUTPUT.txt > tmp.txt But the tags still remain in the text. Can somebody tell my what I... (2 Replies)
Discussion started by: mortl
2 Replies

6. Shell Programming and Scripting

Perl int function solved

Hello, I have the below perl function int to return the integer value from the expression but it is not. I am not sure if something misses out here. Any help on this? Thanks in advance. # Code sample Start my $size = int (`1134 sample_text_here`); print "$size \n"; # Code end ----------... (0 Replies)
Discussion started by: nmattam
0 Replies

7. Shell Programming and Scripting

[SOLVED] Scope of KSH Variable in Perl?

cat test.ksh #!/usr/bin/ksh VAR="Dear Friends \n How are you? \n Have a nice day \n" export VAR echo "Inside test.ksh"; ./test.pl cat test.pl #!/usr/bin/perl print "Inside test.pl \n"; print "$VAR"; Output: ./test.ksh Inside test.ksh Inside test.plWhat I want to achieve is, I... (1 Reply)
Discussion started by: dahlia84
1 Replies

8. Shell Programming and Scripting

perl regex help solved

Hi there I have a list of mac addresses that are in this format 0100237D2136XX 0118A905599EXX 0118A9054E15XX 010003BAF1F3XX 0118A905599EXX 0100237D6522XX 010C53BAF1F3XX 010003BAF1F3XX 010C53BAF1F3XX The 01 is at the beginning has been put on by my software, but the rest is the mac... (0 Replies)
Discussion started by: rethink
0 Replies

9. Shell Programming and Scripting

Saving output from awk into a perl variable

How would I pass awk output to a perl variable? For example, I want to save the value in the 4th column into the variable called test. My best guess is something as follow, but I am sure this isn't correct. $test = system("awk '/NUMBER/{print \$4}' $_"); (8 Replies)
Discussion started by: userix
8 Replies

10. UNIX for Dummies Questions & Answers

Saving Perl scrpits in a UNIX Shell

Hey, i am really new to Perl and UNIX, all i need to know how to know how to save scripts in UNIX? after i get done writing the script i type the command chmod 755 filename, but it I think the shell thinks that is a part of the script, i dont know if i am supposed to type in a save command or... (3 Replies)
Discussion started by: hagrid
3 Replies
Login or Register to Ask a Question