diff count_ref_length.pl @ 0:07745c0958dd draft

Uploaded
author big-tiandm
date Thu, 18 Sep 2014 21:40:25 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/count_ref_length.pl	Thu Sep 18 21:40:25 2014 -0400
@@ -0,0 +1,58 @@
+#!/usr/bin/perl -w
+#Filename:
+#Author: Tian Dongmei
+#Email: tiandm@big.ac.cn
+#Date: 2009-05-06
+#Modified:
+#Description: ɾ³ýmatched reads 
+my $version=1.00;
+
+use strict;
+use Getopt::Long;
+
+my %opts;
+GetOptions(\%opts,"i=s","o=s","h");
+if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
+&usage;
+}
+
+my $filein=$opts{'i'};
+my $fileout=$opts{'o'};
+
+open IN,"<$filein"; #input file  
+open OUT,">$fileout"; #output file  
+
+my ($name,$seq);
+while (my $aline=<IN>) {
+	chomp $aline;
+	if ($aline=~/^>(\S+)/) {
+		$name=$1;
+		while (my $new=<IN>) {
+			chomp $new;
+			if ($new=~/^>(\S+)/) {
+				print OUT $name,"\t",length($seq),"\n";
+				$seq ="";
+				$name=$1;
+				next;
+			}
+			else{$seq .=$new;}
+		}
+	}
+	print OUT $name,"\t",length($seq),"\n";
+}
+ 
+close IN;
+close OUT;
+sub usage{
+print <<"USAGE";
+Version $version
+Usage:
+$0 -i -o
+options:
+-i input file
+-o output file
+-h help
+USAGE
+exit(1);
+}
+