BedRegion: Difference between revisions

From genomewiki
Jump to navigationJump to search
No edit summary
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
         if (ARGC>2) {
         if (ARGC>2) {
           print;
           print;
           print "Will display the minimum start and maximum end position of a be
           print "Will display the minimum start and maximum end position of a bed file
           print "in UCSC-style format (chr4:minstartpos-maxendpos)"
           print "in UCSC-style format (chr4:minstartpos-maxendpos)"
           print ""
           print ""
Line 51: Line 51:
}
}
</pre>
</pre>
[[Category:User Developed Scripts]]

Latest revision as of 23:37, 9 September 2006

#!/usr/bin/gawk -f
# max 11/05
BEGIN { 
        if (ARGC>2) {
          print;
          print "Will display the minimum start and maximum end position of a bed file
          print "in UCSC-style format (chr4:minstartpos-maxendpos)"
          print ""
          print "SYNTAX:"
          print " bedRegion" 
          print "EXAMPLE:"
          print " cat bla.bed | bedRegion"
         exit 1

        }
         FS=" ";
         min=10000000000;
         max=0;
        chrom = "noChrom";
}
        
/track type=wiggle_0/ { wiggle=1;
    next;}
/track/ { wiggle=0; 
            next;}
/browser/ {next;}
/^#.*/ {next;}
/^$/ {next;}


//      { if (wiggle!=1) {
          if ($2 < min) {
           min = $2
          }
        if ($3 > max) {
                max = $3 
        }
        chrom = $1
    }
}

END { 
    if (chrom!="noChrom") 
        print chrom ":" min "-" max; 
    else {
        print "no chrom found, might be a wiggle track or empty";
        exit (1);
    }

}