NCBI C++ Toolkit Cross Reference

  C++/src/gui/packages/pkg_sequence_edit/country_fixup.cpp


/* $Id: country_fixup.cpp 27938 2013-04-26 15:09:55Z filippov $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Igor Filippov */ #include <ncbi_pch.hpp> #include <gui/packages/pkg_sequence_edit/country_fixup.hpp> BEGIN_NCBI_SCOPE using namespace objects; void CCountryFixup::ApplyToBioSource (const CBioSource& biosource, CCmdComposite* composite, const CSeq_entry* se, const CSeqdesc* seqDesq, const CSeq_feat* seqFeat) { CRef<CSerialObject> edited_object; edited_object.Reset((CSerialObject*)CBioSource::GetTypeInfo()->Create()); edited_object->Assign(biosource); CBioSource& edited_biosource = dynamic_cast<CBioSource&>(*edited_object); bool modified = false; ApplyToCountry (edited_biosource,modified); if (modified) { CChangeBioSourceCommand* cmd = new CChangeBioSourceCommand(); CObject* actual = (CObject*) &biosource; cmd->Add(actual, CConstRef<CObject>(edited_object)); composite->AddCommand(*cmd); } } void CCountryFixup::ApplyToCSeq_entry (const CSeq_entry& se, CCmdComposite* composite) { FOR_EACH_SEQDESC_ON_SEQENTRY (it, se) { if ((*it)->IsSource()) { ApplyToBioSource ((*it)->GetSource(), composite, &se, *it, NULL); } } if (se.IsSet()) { FOR_EACH_SEQENTRY_ON_SEQSET (it, se.GetSet()) { ApplyToCSeq_entry (**it, composite); } } } void CCountryFixup::apply_to_seq_and_feat(objects::CSeq_entry_Handle tse, CCmdComposite* composite) { ApplyToCSeq_entry (*(tse.GetCompleteSeq_entry()), composite); CFeat_CI feat (tse, SAnnotSelector(CSeqFeatData::e_Biosrc)); while (feat) { ApplyToBioSource (feat->GetData().GetBiosrc(), composite, NULL, NULL,&(feat->GetOriginalFeature())); ++feat; } } bool CCountryFixup::apply(objects::CSeq_entry_Handle tse, ICommandProccessor* cmdProcessor, string title, bool capitalize_after_colon) { if (tse) { m_capitalize_after_colon = capitalize_after_colon; CRef<CCmdComposite> composite(new CCmdComposite(title)); apply_to_seq_and_feat(tse,composite); cmdProcessor->Execute(composite.GetPointer()); return true; } else return false; } void CCountryFixup::ApplyToCountry(CBioSource& biosource, bool& modified) { if (biosource.IsSetSubtype()) { EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(subsource,biosource) if ((*subsource)->IsSetSubtype() && (*subsource)->IsSetName() && (*subsource)->GetSubtype() == CSubSource::eSubtype_country) { string country = (*subsource)->GetName(); string new_country = CCountries::CountryFixupItem(country,m_capitalize_after_colon); if (!new_country.empty() && new_country != country) { (*subsource)->SetName(new_country); modified = true; } } } } END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.