]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed bug in psl2bed conversion
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 9 Sep 2009 09:00:38 +0000 (09:00 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 9 Sep 2009 09:00:38 +0000 (09:00 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@666 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/UCSC/BED.pm
code_perl/Maasha/UCSC/PSL.pm

index 3d873e660ec6d85b92a48b341e7c5fe940a4cd9c..77988f75c0c18b404e01b0e676f9f3c09741ce17 100644 (file)
@@ -463,9 +463,9 @@ sub biopiece2bed
     # record is converted and undef is returned if 
     # convertion failed.
 
-    # IMPORTANT! The BED_END and THICK_END positions
+    # IMPORTANT! The chromEnd and thickEnd positions
     # will be the inexact position used in the
-    # UCSC scheme.
+    # UCSC scheme (+1 to all ends).
     
     my ( $bp_record,   # hashref
          $cols,        # number of columns in BED entry - OPTIONAL (but faster)
@@ -477,9 +477,9 @@ sub biopiece2bed
 
     $cols ||= 12;   # max number of columns possible
 
-    $bed_entry[ chrom ]      = $bp_record->{ "CHR" }     ||
-                               $bp_record->{ "S_ID" }    ||
-                               return undef;
+    $bed_entry[ chrom ] = $bp_record->{ "CHR" }  ||
+                          $bp_record->{ "S_ID" } ||
+                          return undef;
 
     if ( defined $bp_record->{ "CHR_BEG" } ) {
         $bed_entry[ chromStart ] = $bp_record->{ "CHR_BEG" };
@@ -490,15 +490,13 @@ sub biopiece2bed
     }
 
     if ( defined $bp_record->{ "CHR_END" } ) {
-        $bed_entry[ chromEnd ] = $bp_record->{ "CHR_END" };
+        $bed_entry[ chromEnd ] = $bp_record->{ "CHR_END" } + 1;
     } elsif ( defined $bp_record->{ "S_END" }) {
-        $bed_entry[ chromEnd ] = $bp_record->{ "S_END" };
+        $bed_entry[ chromEnd ] = $bp_record->{ "S_END" } + 1;
     } else {
         return undef;
     }
 
-    $bed_entry[ chromEnd ]++;
-
     return wantarray ? @bed_entry : \@bed_entry if $cols == 3;
 
     $bed_entry[ name ] = $bp_record->{ "Q_ID" } || return wantarray ? @bed_entry : \@bed_entry;
@@ -556,16 +554,16 @@ sub biopiece2bed
         $bed_entry[ blockCount ]  = $bp_record->{ "BLOCK_COUNT" };
         $bed_entry[ blockSizes ]  = $bp_record->{ "BLOCK_LENS" };
         $bed_entry[ blockStarts ] = join ",", @begs;
-        $bed_entry[ thickEnd ]    = $bp_record->{ "THICK_END" } + 1;
+        $bed_entry[ thickEnd ]    = $bp_record->{ "THICK_END" } + 1;
     }
     elsif ( defined $bp_record->{ "BLOCK_COUNT" } and
-         defined $bp_record->{ "BLOCK_LENS" }  and
-         defined $bp_record->{ "Q_BEGS" } )
+            defined $bp_record->{ "BLOCK_LENS" }  and
+            defined $bp_record->{ "Q_BEGS" } )
     {
         $bed_entry[ blockCount ]  = $bp_record->{ "BLOCK_COUNT" };
         $bed_entry[ blockSizes ]  = $bp_record->{ "BLOCK_LENS" };
         $bed_entry[ blockStarts ] = $bp_record->{ "Q_BEGS" };
-        $bed_entry[ thickEnd  ]   = $bp_record->{ "THICK_END" } + 1;
+        $bed_entry[ thickEnd  ]   = $bp_record->{ "THICK_END" } + 1;
     }
 
     return wantarray ? @bed_entry : \@bed_entry;
index 19f6e71f5ea968d620a1486d2d9f81908f43fdcb..d803a962455d45bdff63baec652cd09210289d5f 100644 (file)
@@ -140,9 +140,9 @@ sub psl2biopiece
         REC_TYPE     => "PSL",
         BLOCK_LENS   => $psl->[ blockSizes ],
         SNUMINSERT   => $psl->[ tNumInsert ],
-        Q_END        => $psl->[ qEnd ],
+        Q_END        => $psl->[ qEnd ] - 1,
         SBASEINSERT  => $psl->[ tBaseInsert ],
-        S_END        => $psl->[ tEnd ],
+        S_END        => $psl->[ tEnd ] - 1,
         QBASEINSERT  => $psl->[ qBaseInsert ],
         REPMATCHES   => $psl->[ repMatches ],
         QNUMINSERT   => $psl->[ qNumInsert ],