Esempio 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")
}
Esempio n. 2
0
func getPdbChain(fp string) *pdb.Chain {
	b := path.Base(fp)
	if !strings.HasSuffix(b, ".fmap") {
		util.Fatalf("Expected file named 'something.fmap' but got '%s'.", b)
	}
	idAndChain := b[0 : len(b)-5]
	if len(idAndChain) != 5 {
		util.Fatalf("Expected 4-letter PDB id concatenated with 1-letter "+
			"chain identifier, but got '%s' instead.", idAndChain)
	}

	pdbName := idAndChain[0:4]
	chainId := idAndChain[4]
	pdbCat := idAndChain[1:3]
	pdbFile := fmt.Sprintf("pdb%s.ent.gz", pdbName)

	pdbPath := path.Join(util.FlagPdbDir, pdbCat, pdbFile)

	entry := util.PDBRead(pdbPath)
	chain := entry.Chain(chainId)
	if chain == nil {
		util.Fatalf("Could not find chain '%c' in PDB entry '%s'.",
			chainId, pdbPath)
	}
	return chain
}