]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed a number of bugs in PSL
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 17 Jun 2009 11:09:22 +0000 (11:09 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 17 Jun 2009 11:09:22 +0000 (11:09 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@539 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/blast_seq
bp_bin/blat_seq
bp_bin/write_psl
code_perl/Maasha/UCSC.pm
code_perl/Maasha/UCSC/PSL.pm

index 00270a3fa341987110c8a1635a703da37a436fa7..de78c35d4a2c1419027617068e2257f1c8f8452d 100755 (executable)
@@ -212,8 +212,6 @@ sub get_tab_entry
     
         @fields = split /\s+/, $line;
 
-        use Data::Dumper;
-
         return wantarray ? @fields : \@fields;
     }
 
index e7dbc3a725e2d67b2065157cbcfcbbd34da657f7..342c5cd5a20c1602167b0c0057b8cb101e2b201d 100755 (executable)
@@ -87,11 +87,15 @@ $blat_args .= " -q=$type";
 
 $result_file = "$tmp_dir/blat.psl";
 
-Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file > /dev/null 2>&1" );
+if ( $options->{ 'verbose' } ) {
+    Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file" );
+} else {
+    Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file > /dev/null 2>&1" );
+}
 
 unlink $query_file;
 
-$fh_in = Maasha::Filesys::file_read_opem( $result_file );
+$fh_in = Maasha::Filesys::file_read_open( $result_file );
 
 while ( $entry = Maasha::UCSC::PSL::psl_entry_get( $fh_in ) )
 {
index 404e21aea0fbbccb31e2b30d468d5fc5a07c9ec0..6956a23985bb423db3c14a88f15fd210a3400870 100755 (executable)
@@ -57,8 +57,8 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
 
     if ( $record->{ "REC_TYPE" } and $record->{ "REC_TYPE" } eq "PSL" )
     {
-        Maasha::UCSC::psl_put_header( $fh ) if $first;
-        Maasha::UCSC::psl_put_entry( $record, $fh );
+        Maasha::UCSC::PSL::psl_put_header( $fh ) if $first;
+        Maasha::UCSC::PSL::psl_put_entry( $record, $fh );
         $first = 0;
     }
 }
index fad1401a38d6744cbcffea9736b0dae50ae54c90..5a8ad956ba122cc05953eefe542151d4ff1f4b9c 100644 (file)
@@ -683,68 +683,6 @@ CREATE TABLE $table (
 }
 
 
-sub psl_put_header
-{
-    # Martin A. Hansen, September 2007.
-
-    # Write a PSL header to file.
-
-    my ( $fh,  # file handle  - OPTIONAL
-       ) = @_;
-
-    # Returns nothing.
-
-    $fh = \*STDOUT if not $fh;
-
-    print $fh qq(psLayout version 3
-match   mis-    rep.    N's     Q gap   Q gap   T gap   T gap   strand  Q               Q       Q       Q       T               T       T       T       block   blockSizes      qStart        match   match           count   bases   count   bases           name            size    start   end     name            size    start   end     count
---------------------------------------------------------------------------------------------------------------------------------------------------------------- 
-);
-}
-
-
-sub psl_put_entry
-{
-    # Martin A. Hansen, September 2007.
-
-    # Write a PSL entry to file.
-
-    my ( $record,       # hashref
-         $fh,           # file handle  -  OPTIONAL
-       ) = @_;
-
-    # Returns nothing.
-
-    $fh = \*STDOUT if not $fh;
-
-    my @output;
-
-    push @output, $record->{ "MATCHES" };
-    push @output, $record->{ "MISMATCHES" };
-    push @output, $record->{ "REPMATCHES" };
-    push @output, $record->{ "NCOUNT" };
-    push @output, $record->{ "QNUMINSERT" };
-    push @output, $record->{ "QBASEINSERT" };
-    push @output, $record->{ "SNUMINSERT" };
-    push @output, $record->{ "SBASEINSERT" };
-    push @output, $record->{ "STRAND" };
-    push @output, $record->{ "Q_ID" };
-    push @output, $record->{ "Q_LEN" };
-    push @output, $record->{ "Q_BEG" };
-    push @output, $record->{ "Q_END" } + 1;
-    push @output, $record->{ "S_ID" };
-    push @output, $record->{ "S_LEN" };
-    push @output, $record->{ "S_BEG" };
-    push @output, $record->{ "S_END" } + 1;
-    push @output, $record->{ "BLOCK_COUNT" };
-    push @output, $record->{ "BLOCK_LENS" };
-    push @output, $record->{ "Q_BEGS" };
-    push @output, $record->{ "S_BEGS" };
-
-    print $fh join( "\t", @output ), "\n";
-}
-
-
 sub psl_upload_to_ucsc
 {
     # Martin A. Hansen, September 2007.
index 75dfb590ebb6b05a0160afed8ff67402e303fa5e..d0ff611635e01c8ff9bf6e714af95c30965f1bd6 100644 (file)
@@ -109,11 +109,13 @@ sub psl_entry_get
 
     while ( $line = <$fh> )
     {
+        next if $line !~ /^\d/;
+
         chomp $line;
 
         @fields = split "\t", $line;
 
-        return wantarray ? @fields : \@fields if scalar @fields == 21;
+        return wantarray ? @fields : \@fields;   # 21 fields
     }
 
     return undef;
@@ -135,27 +137,27 @@ sub psl2biopiece
 
     %record = (
         REC_TYPE     => "PSL",
-        BLOCK_LENS   => $psl->{ 'blockSize' },
-        SNUMINSERT   => $psl->{ 'tNumInsert' },
-        Q_END        => $psl->{ 'qEnd' },
-        SBASEINSERT  => $psl->{ 'tBaseInsert' },
-        S_END        => $psl->{ 'tEnd' },
-        QBASEINSERT  => $psl->{ 'qBaseInsert' },
-        REPMATCHES   => $psl->{ 'repMatches' },
-        QNUMINSERT   => $psl->{ 'qNumInsert' },
-        MISMATCHES   => $psl->{ 'misMatches' },
-        BLOCK_COUNT  => $psl->{ 'blockCount' },
-        Q_LEN        => $psl->{ 'qSize' },
-        S_ID         => $psl->{ 'tName' },
-        STRAND       => $psl->{ 'strand' },
-        Q_ID         => $psl->{ 'qName' },
-        MATCHES      => $psl->{ 'matches' },
-        S_LEN        => $psl->{ 'tSize' },
-        NCOUNT       => $psl->{ 'nCount' },
-        Q_BEGS       => $psl->{ 'qStarts' },
-        S_BEGS       => $psl->{ 'tStarts' },
-        S_BEG        => $psl->{ 'tStart' },
-        Q_BEG        => $psl->{ 'qStart ' },
+        BLOCK_LENS   => $psl->[ blockSizes ],
+        SNUMINSERT   => $psl->[ tNumInsert ],
+        Q_END        => $psl->[ qEnd ],
+        SBASEINSERT  => $psl->[ tBaseInsert ],
+        S_END        => $psl->[ tEnd ],
+        QBASEINSERT  => $psl->[ qBaseInsert ],
+        REPMATCHES   => $psl->[ repMatches ],
+        QNUMINSERT   => $psl->[ qNumInsert ],
+        MISMATCHES   => $psl->[ misMatches ],
+        BLOCK_COUNT  => $psl->[ blockCount ],
+        Q_LEN        => $psl->[ qSize ],
+        S_ID         => $psl->[ tName ],
+        STRAND       => $psl->[ strand ],
+        Q_ID         => $psl->[ qName ],
+        MATCHES      => $psl->[ matches ],
+        S_LEN        => $psl->[ tSize ],
+        NCOUNT       => $psl->[ nCount ],
+        Q_BEGS       => $psl->[ qStarts ],
+        S_BEGS       => $psl->[ tStarts ],
+        S_BEG        => $psl->[ tStart ],
+        Q_BEG        => $psl->[ qStart ],
     );
 
     $record{ "SCORE" } = $record{ "MATCHES" } + int( $record{ "REPMATCHES" } / 2 ) - $record{ "MISMATCHES" } - $record{ "QNUMINSERT" } - $record{ "SNUMINSERT" };
@@ -189,6 +191,70 @@ sub psl_calc_score
 }
 
 
+sub psl_put_header
+{
+    # Martin A. Hansen, September 2007.
+
+    # Write a PSL header to file.
+
+    my ( $fh,  # file handle  - OPTIONAL
+       ) = @_;
+
+    # Returns nothing.
+
+    $fh = \*STDOUT if not $fh;
+
+    print $fh qq(psLayout version 3
+match   mis-    rep.    N's     Q gap   Q gap   T gap   T gap   strand  Q               Q       Q       Q       T               T       T       T       block   blockSizes      qStart        match   match           count   bases   count   bases           name            size    start   end     name            size    start   end     count
+--------------------------------------------------------------------------------------------------------------------------------------------------------------- 
+);
+}
+
+
+sub psl_put_entry
+{
+    # Martin A. Hansen, September 2007.
+
+    # Write a PSL entry to file.
+
+    my ( $record,       # hashref
+         $fh,           # file handle  -  OPTIONAL
+       ) = @_;
+
+    # Returns nothing.
+
+    $fh = \*STDOUT if not $fh;
+
+    my @output;
+
+    push @output, $record->{ "MATCHES" };
+    push @output, $record->{ "MISMATCHES" };
+    push @output, $record->{ "REPMATCHES" };
+    push @output, $record->{ "NCOUNT" };
+    push @output, $record->{ "QNUMINSERT" };
+    push @output, $record->{ "QBASEINSERT" };
+    push @output, $record->{ "SNUMINSERT" };
+    push @output, $record->{ "SBASEINSERT" };
+    push @output, $record->{ "STRAND" };
+    push @output, $record->{ "Q_ID" };
+    push @output, $record->{ "Q_LEN" };
+    push @output, $record->{ "Q_BEG" };
+    push @output, $record->{ "Q_END" } + 1;
+    push @output, $record->{ "S_ID" };
+    push @output, $record->{ "S_LEN" };
+    push @output, $record->{ "S_BEG" };
+    push @output, $record->{ "S_END" } + 1;
+    push @output, $record->{ "BLOCK_COUNT" };
+    push @output, $record->{ "BLOCK_LENS" };
+    push @output, $record->{ "Q_BEGS" };
+    push @output, $record->{ "S_BEGS" };
+
+    print $fh join( "\t", @output ), "\n";
+}
+
+
+
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<