]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/find_genes
upgraded find_genes
[biopieces.git] / bp_bin / find_genes
index f80fa88f7022e56851dc4d9d93d055121f6b04e9..2880a3627ed18930122f7860ac5ec906f8d9152e 100755 (executable)
@@ -37,7 +37,7 @@ use Maasha::Filesys;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $tmp_dir, $tmp_file, $fh_out, $fh_in, $entry, $chunk, @lines, $line, $s_id, $type, $s_beg, $s_end, $strand, @fields );
+my ( $options, $in, $out, $record, $tmp_dir, $tmp_file, $fh_out, $fh_in, $entry, $chunk, @lines, $line, $s_id, $type, $s_beg, $s_end, $strand, @fields, $def );
 
 $options = Maasha::Biopieces::parse_options();
 
@@ -57,7 +57,11 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
     Maasha::Biopieces::put_record( $record, $out );
 }
 
-Maasha::Common::run( "draft_prodigal.pl", "< $tmp_file > $tmp_file.out 2> /dev/null" );
+if ( $options->{ 'verbise' } ) {
+    Maasha::Common::run( "prodigal", "< $tmp_file > $tmp_file.out" );
+} else {
+    Maasha::Common::run( "prodigal", "< $tmp_file > $tmp_file.out 2> /dev/null" );
+}
 
 $fh_in = Maasha::Filesys::file_read_open( "$tmp_file.out" );
 
@@ -71,46 +75,63 @@ while ( $chunk = <$fh_in> )
 
     $line = shift @lines;
 
-    if ( $line =~ /.*>(.+)/ )
+    if ( $line =~ /^DEFINITION\s+(.+)/ )
     {
-        $s_id = $1;
-
-        foreach $line ( @lines )
-        {
-            @fields = split " ", $line;
+        $def  = $1;
 
-            $type   = $fields[ 0 ];
+        if ( $def =~ /seqhdr="([^"]+)"/ ) {
+            $s_id = $1;
+        } else {
+            Maasha::Common::error( qq(BAD sequence header: $def) );
+        }
 
-            if ( $fields[ 1 ] =~ /complement/ ) {
-                $strand = "-"; 
-            } else {
-                $strand = "+"; 
-            }
+        $line = shift @lines;
 
-            if ( $fields[ 1 ] =~ /(\d+)\.\.>?(\d+)/ )
-            {
-                $s_beg = $1;
-                $s_end = $2;
-            }
-            else
+        if ( $line =~ /^FEATURES/ )
+        {
+            foreach $line ( @lines )
             {
-                Maasha::Common::error( qq(BAD locator: $line) );
+                next if $line =~ /.+\//;
+
+                @fields = split " ", $line;
+
+                $type   = $fields[ 0 ];
+
+                if ( $fields[ 1 ] =~ /complement/ ) {
+                    $strand = "-"; 
+                } else {
+                    $strand = "+"; 
+                }
+
+                if ( $fields[ 1 ] =~ /(\d+)\.\.>?(\d+)/ )
+                {
+                    $s_beg = $1;
+                    $s_end = $2;
+                }
+                else
+                {
+                    Maasha::Common::error( qq(BAD locator: $line) );
+                }
+
+                $record = {
+                    S_ID   => $s_id,
+                    S_BEG  => $s_beg - 1,
+                    S_END  => $s_end - 1,
+                    Q_ID   => $type,
+                    STRAND => $strand,
+                };
+
+                Maasha::Biopieces::put_record( $record, $out );
             }
-
-            $record = {
-                S_ID   => $s_id,
-                S_BEG  => $s_beg - 1,
-                S_END  => $s_end - 1,
-                Q_ID   => $type,
-                STRAND => $strand,
-            };
-
-            Maasha::Biopieces::put_record( $record, $out );
+        }
+        else
+        {
+            Maasha::Common::error( qq(BAD feature: $line) );
         }
     }
     else
     {
-        Maasha::Commom::error( qq(BAD definition: $line) );
+        Maasha::Common::error( qq(BAD definition: $line) );
     }
 }