#include "psublast/psublast.h" #include typedef struct region { int b, e; int flag; struct region *link; } region_list_t, *region_list_ptr; typedef struct line { char orf[100]; int len; int b, e; } hit_t, *hit_ptr; #define Usage "%s " static region_list_ptr new_region(int b, int e, region_list_ptr link); static int insert_region(region_list_ptr *rlist, int b, int e, int flag); int main(int argc, char *argv[]) { FILE *fp; char buf[1000], *tok; char *counts; int Length; int i, start, end, from, to; if (argc!=4) fatalf(Usage, argv[0]); Length = atoi(argv[3]); counts = (char *)malloc(Length*sizeof(char))-1; memset(counts+1,0,Length); fp = ckopen(argv[1],"r"); while (fgets(buf,1000,fp)!=NULL) { tok = strtok(buf, " "); tok = strtok(NULL, " "); from = atoi(tok); tok = strtok(NULL, " \n"); to = atoi(tok); for (i=from; i<=to; i++) counts[i] = 1; } fclose(fp); fp = ckopen(argv[2],"r"); while (fgets(buf,1000,fp)!=NULL) { tok = strtok(buf, " "); tok = strtok(NULL, " "); from = atoi(tok); tok = strtok(NULL, " \n"); to = atoi(tok); for (i=from; i<=to; i++) counts[i] = 2; } fclose(fp); for (i=1; i<=Length; i++) { if (i==1 || (counts[i-1]!=1 && counts[i]==1)) start = i; if (i==Length || (counts[i-1]==1 && counts[i]!=1)) { end = i-1; printf(">SBO %d %d\n", start, end); } } free(counts+1); exit(0); } static region_list_ptr new_region(int b, int e, region_list_ptr link) { region_list_ptr new = ckalloc(sizeof(region_list_t)); new->b = b; new->e = e; new->link = link; return new; } -------------------------------------------------------------------- #!/usr/local/bin/perl my $CUTOFF = 0.9; my $prevfrom = -1; my $prevto = -1; # Read-in a sorted aligns file # SBO 1834191 1834421 >Contig_1_10.15 227 423 r 0.578723 0.680000 while (<>) { chomp; /^>SBO\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S)\s(\S+)\s+(\S+)$/ or die "Illegal line. $_"; my ($from,$to,$other,$from_other,$to_other,$ori,$pctid,$max100) = ($1,$2,$3,$4,$5,$6,$7,$8); next if ($max100<$CUTOFF); if ($from > $prevto) { print ">SBO $prevfrom $prevto\n"; $prevfrom = $from; $prevto = $to; } else { if ($to>$prevto) { $prevto = $to; } } }