diff non_miRNA_reads.pl @ 50:7b5a48b972e9 draft

Uploaded
author big-tiandm
date Fri, 05 Dec 2014 00:11:02 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/non_miRNA_reads.pl	Fri Dec 05 00:11:02 2014 -0500
@@ -0,0 +1,62 @@
+#!/usr/bin/perl -w
+#Filename:
+#Author: Tian Dongmei
+#Email: tiandm@big.ac.cn
+#Date: 2013/7/19
+#Modified:
+#Description: 
+my $version=1.00;
+
+use strict;
+use Getopt::Long;
+
+my %opts;
+GetOptions(\%opts,"i=s","fa=s","o=s","h");
+if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
+&usage;
+}
+
+my $filein=$opts{'fa'};
+my $fileout=$opts{'o'};
+
+open IN,"<$filein"; #input file  
+my (%fa,%seq);
+while (my $aline=<IN>){
+	chomp $aline;
+	$aline=~s/^>//;
+	my $seq=<IN>;
+	chomp $seq;
+	#$seq{$seq}=$aline;
+	$fa{$aline}=$seq;
+}
+close IN;
+
+open IN,"<$opts{i}";
+while(my $aline=<IN>){
+	chomp $aline;
+	if($aline=~/^\S+_x\d+/){
+		$aline=~/^(\S+_x\d+)/;
+		my $name=$1;
+		delete($fa{$name});
+	}
+}
+close IN;
+
+open OUT,">$fileout"; #output file  
+foreach my $key (keys %fa) {
+	print OUT ">$key\n$fa{$key}\n";
+}
+close OUT;
+sub usage{
+print <<"USAGE";
+Version $version
+Usage:
+$0 -i -o
+options:
+-i input file
+-o output file
+-h help
+USAGE
+exit(1);
+}
+