From b5d9b1a734c518bc14158ce0b34dcbc76928314e Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 18 Nov 2008 03:59:51 +0000 Subject: [PATCH] clean up git-svn-id: http://biopieces.googlecode.com/svn/trunk@316 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/Biopieces.pm | 14 ++++++++++ code_perl/Maasha/UCSC.pm | 49 +++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index d5a33fe..ebf51a9 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -4518,6 +4518,20 @@ sub script_write_bed Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); } + elsif ( $record->{ 'tBaseInsert' } ) # ---- Dirty addition to allow Affy data from MySQL to be dumped ---- + { + $record = Maasha::UCSC::psl2record( $record ); + + $new_record = $record; + $new_record->{ "CHR" } = $record->{ "S_ID" }; + $new_record->{ "CHR_BEG" } = $record->{ "S_BEG" }; + $new_record->{ "CHR_END" } = $record->{ "S_END" }; + $new_record->{ "Q_ID" } = $record->{ "Q_ID" }; + $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; + $new_record->{ "STRAND" } = $record->{ "STRAND" }; + + Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); + } elsif ( $record->{ "CHR" } and defined $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) # ---- Generic data from tables ---- { Maasha::UCSC::bed_put_entry( $record, $fh, $cols ); diff --git a/code_perl/Maasha/UCSC.pm b/code_perl/Maasha/UCSC.pm index 7ae2e37..fcd08ff 100644 --- a/code_perl/Maasha/UCSC.pm +++ b/code_perl/Maasha/UCSC.pm @@ -644,11 +644,11 @@ sub bed_upload_to_ucsc $args = join " ", $options->{ "database" }, $options->{ "table" }, "-tmpDir=$tmp_dir", $file; } - if ( $options->{ "sec_struct" } ) + if ( $options->{ "table" } =~ /rnaSecStr/ ) { $table = $options->{ "table" }; - Maasha::Common::error( "Attempt to load secondary structure track without 'rnaSecStr' in table name" ) if not $table =~ /rnaSecStr/; + print qq(uploading secondary structure table:"$table"\n) if $options->{ "verbose" }; $sql_file = "$tmp_dir/upload_RNA_SS.sql"; @@ -688,6 +688,50 @@ CREATE TABLE $table ( # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PSL format <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +sub psl2record +{ + # Martin A. Hansen, November 2008 + + # Converts PSL record keys to Biopiece record keys. + + my ( $psl, # hashref + ) = @_; + + # returns hashref + + my %record; + + %record = ( + REC_TYPE => "PSL", + BLOCKSIZES => $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' }, + BLOCKCOUNT => $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" }; + $record{ "SPAN" } = $record{ "Q_END" } - $record{ "Q_BEG" }; + + return wantarray ? %record : \%record; +} + sub psl_get_entry { @@ -982,6 +1026,7 @@ sub ucsc_config_put_entry priority useScore visibility + maxHeightPixels color type ); } -- 2.39.5