Ejemplo n.º 1
0
func main() {
	libFile := util.Arg(0)
	lib := util.FragmentLibrary(libFile)

	stderrf("Loading PDB files into memory...\n")
	entries := make([]*pdb.Entry, util.NArg()-1)
	for i, pdbfile := range flag.Args()[1:] {
		entries[i] = util.PDBRead(pdbfile)
	}

	stderrf("Comparing the results of old fragbag and new fragbag on " +
		"each PDB file...\n")
	for _, entry := range entries {
		stderrf("Testing %s...\n", entry.Path)
		fmt.Printf("Testing %s\n", entry.Path)

		// Try to run old fragbag first. The output is an old-style BOW.
		oldBowStr, err := runOldFragbag(libFile, entry.Path, lib.Size(),
			lib.FragmentSize())
		if err != nil {
			fmt.Println(err)
			fmt.Printf("The output was:\n%s\n", oldBowStr)
			divider()
			continue
		}

		oldBow, err := bow.NewOldStyleBow(lib.Size(), oldBowStr)
		if err != nil {
			fmt.Printf("Could not parse the following as an old style "+
				"BOW:\n%s\n", oldBowStr)
			fmt.Printf("%s\n", err)
			divider()
			continue
		}

		// Now use package fragbag to compute a BOW.
		var newBow bow.BOW
		if flagOldStyle {
			newBow = bow.ComputeBOW(lib, bow.PDBEntryOldStyle{entry})
		} else {
			newBow = bow.ComputeBOW(lib, entry)
		}

		// Create a diff and check if they are the same. If so, we passed.
		// Otherwise, print an error report.
		diff := bow.NewBowDiff(oldBow, newBow)
		if diff.IsSame() {
			fmt.Println("PASSED.")
			divider()
			continue
		}

		// Ruh roh...
		fmt.Println("FAILED.")
		fmt.Printf("\nOld BOW:\n%s\n\nNew BOW:\n%s\n", oldBow, newBow)
		fmt.Printf("\nDiff:\n%s\n", diff)
		divider()
	}
	stderrf("Done!\n")
}
Ejemplo n.º 2
0
func main() {
	dbPath := util.Arg(0)
	fragLibDir := util.Arg(1)
	pdbFiles := flag.Args()[2:]

	util.Assert(createBowDb(dbPath, fragLibDir, pdbFiles))

	db, err := bow.OpenDB(dbPath)
	util.Assert(err)

	bowOpts := bow.SearchDefault
	bowOpts.Limit = 200
	mattOpts := matt.DefaultConfig
	mattOpts.Verbose = false

	chains := createChains(pdbFiles)
	mattArgs := createMattArgs(chains)

	tabw := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
	header := []byte(
		"BOW entry\t" +
			"BOW chain\t" +
			"BOW dist\t" +
			"Matt entry\t" +
			"Matt chain\t" +
			"Matt dist\n")
	for i, chain := range chains {
		marg := mattArgs[i]

		bowOrdered := getBowOrdering(db, bowOpts, chain)
		mattOrdered := getMattOrdering(mattOpts, marg, mattArgs)

		fmt.Printf("Ordering for %s (chain %c)\n",
			chain.Entry.IdCode, chain.Ident)

		compared := comparison([2]ordering{bowOrdered, mattOrdered})
		tabw.Write(header)
		tabw.Write([]byte(compared.String()))
		tabw.Flush()
		fmt.Println("\n")
	}

	util.Assert(db.Close())
}
Ejemplo n.º 3
0
func main() {
	db := util.OpenBOWDB(util.Arg(0))

	// Set our search options.
	bowOpts := bow.SearchDefault
	bowOpts.Limit = -1

	fmt.Println("QueryID\tResultID\tCosine\tEuclid")
	for _, entry := range db.Entries {
		results := db.SearchEntry(bowOpts, entry)

		for _, result := range results {
			fmt.Printf("%s\t%c\t%s\t%c\t%0.4f\t%0.4f\n",
				entry.Id, result.Entry.Id, result.Cosine, result.Euclid)
		}
		fmt.Println("")
	}

	util.Assert(db.Close())
}
Ejemplo n.º 4
0
func main() {
	fmapPath := util.Arg(0)

	fmap := util.FmapRead(fmapPath)
	qchain := getPdbChain(fmapPath)
	stats := newSequenceStats(qchain.Sequence)

	total, trueps := 0, 0
	qcorrupt, tcorrupt := 0, 0
	for _, frags := range fmap.Segments {
		for _, frag := range frags.Frags {
			hit := frag.Hit

			if frag.IsCorrupt() {
				tcorrupt += 1
				stats.incTCorrupt(hit)
				continue
			}

			qatoms := qchain.SequenceCaAtomSlice(hit.QueryStart-1, hit.QueryEnd)
			if qatoms == nil {
				qcorrupt += 1
				stats.incQCorrupt(hit)
				continue
			}

			if len(qatoms) != len(frag.CaAtoms) {
				util.Fatalf("Uncomparable lengths. Query is (%d, %d) while "+
					"template is (%d, %d). Length of query CaAtoms: %d, "+
					"length of template CaAtoms: %d",
					hit.QueryStart, hit.QueryEnd,
					hit.TemplateStart, hit.TemplateEnd,
					len(qatoms), len(frag.CaAtoms))
			}

			if rmsd.QCRMSD(qatoms, frag.CaAtoms) <= flagRmsd {
				trueps += 1
				stats.incTruePs(hit)
			}
			total += 1
			stats.incTotal(hit)
		}
	}

	coveredResidues := 0
	for _, resStats := range stats {
		if resStats.trueps >= 1 {
			coveredResidues += 1
		}
	}
	coverage := float64(coveredResidues) / float64(len(qchain.Sequence))

	fmt.Printf("RMSDThreshold: %f\n", flagRmsd)
	fmt.Printf("TotalFragments: %d\n", total)
	fmt.Printf("TruePositives: %d\n", trueps)
	fmt.Printf("Precision: %f\n", float64(trueps)/float64(total))
	fmt.Printf("CorruptQuery: %d\n", qcorrupt)
	fmt.Printf("CorruptTemplate: %d\n", tcorrupt)
	fmt.Printf("TotalResidues: %d\n", len(qchain.Sequence))
	fmt.Printf("CoveredResidues: %d\n", coveredResidues)
	fmt.Printf("Coverage: %f\n", coverage)
}