Skip to content
Snippets Groups Projects
Commit 3d19c9e1 authored by edgrif's avatar edgrif
Browse files

handle NULL return from dna routines.

parent 357293aa
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,9 @@
*
* Exported functions: See zmapWindow_P.h
* HISTORY:
* Last edited: Oct 16 14:17 2009 (edgrif)
* Last edited: Nov 18 16:17 2009 (edgrif)
* Created: Mon Jan 9 10:25:40 2006 (edgrif)
* CVS info: $Id: zmapWindowFeature.c,v 1.165 2009-10-16 13:26:13 edgrif Exp $
* CVS info: $Id: zmapWindowFeature.c,v 1.166 2009-11-18 16:29:39 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -666,12 +666,13 @@ FooCanvasGroup *zmapWindowFeatureItemsMakeGroup(ZMapWindow window, GList *featur
* there's no falling over phase values and stop codons... */
char *zmapWindowFeatureTranscriptFASTA(ZMapFeature feature, gboolean spliced, gboolean cds_only)
{
ZMapFeatureContext context;
char *peptide_fasta = NULL;
char *peptide_fasta = NULL ;
ZMapFeatureContext context ;
if((feature->type == ZMAPSTYLE_MODE_TRANSCRIPT) &&
((context = (ZMapFeatureContext)zMapFeatureGetParentGroup((ZMapFeatureAny)feature,
ZMAPFEATURE_STRUCT_CONTEXT))))
if((feature->type == ZMAPSTYLE_MODE_TRANSCRIPT)
&& ((context = (ZMapFeatureContext)zMapFeatureGetParentGroup((ZMapFeatureAny)feature,
ZMAPFEATURE_STRUCT_CONTEXT))))
{
ZMapPeptide peptide;
char *dna, *seq_name = NULL, *gene_name = NULL;
......@@ -679,23 +680,27 @@ char *zmapWindowFeatureTranscriptFASTA(ZMapFeature feature, gboolean spliced, gb
seq_name = (char *)g_quark_to_string(context->original_id);
gene_name = (char *)g_quark_to_string(feature->original_id);
dna = zMapFeatureGetTranscriptDNA(context, feature, spliced, cds_only) ;
/* Adjust for when its known that the start exon is incomplete.... */
if (feature->feature.transcript.flags.start_not_found)
start_incr = feature->feature.transcript.start_phase - 1 ; /* Phase values are 1 <= phase <= 3 */
if ((dna = zMapFeatureGetTranscriptDNA(feature, spliced, cds_only)))
{
/* Adjust for when its known that the start exon is incomplete.... */
if (feature->feature.transcript.flags.start_not_found)
start_incr = feature->feature.transcript.start_phase - 1 ; /* Phase values are 1 <= phase <= 3 */
peptide = zMapPeptideCreate(seq_name, gene_name, (dna + start_incr), NULL, TRUE) ;
peptide = zMapPeptideCreate(seq_name, gene_name, (dna + start_incr), NULL, TRUE) ;
/* Note that we do not include the "Stop" in the peptide length, is this the norm ? */
pep_length = zMapPeptideLength(peptide) ;
if (zMapPeptideHasStopCodon(peptide))
pep_length-- ;
/* Note that we do not include the "Stop" in the peptide length, is this the norm ? */
pep_length = zMapPeptideLength(peptide) ;
if (zMapPeptideHasStopCodon(peptide))
pep_length-- ;
peptide_fasta = zMapFASTAString(ZMAPFASTA_SEQTYPE_AA,
seq_name, "Protein",
gene_name, pep_length,
zMapPeptideSequence(peptide));
peptide_fasta = zMapFASTAString(ZMAPFASTA_SEQTYPE_AA,
seq_name, "Protein",
gene_name, pep_length,
zMapPeptideSequence(peptide));
g_free(dna) ;
}
}
return peptide_fasta;
......
......@@ -27,9 +27,9 @@
* Exported functions: ZMap/zmapWindows.h
*
* HISTORY:
* Last edited: Jul 3 16:54 2009 (rds)
* Last edited: Nov 18 16:17 2009 (edgrif)
* Created: Thu Mar 10 07:56:27 2005 (edgrif)
* CVS info: $Id: zmapWindowMenus.c,v 1.62 2009-07-27 03:15:13 rds Exp $
* CVS info: $Id: zmapWindowMenus.c,v 1.63 2009-11-18 16:30:02 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -410,14 +410,18 @@ static void dnaMenuCB(int menu_item_id, gpointer callback_data)
}
else if (feature->type == ZMAPSTYLE_MODE_TRANSCRIPT)
{
dna = zMapFeatureGetTranscriptDNA(context, feature, spliced, cds) ;
dna = zMapFeatureGetTranscriptDNA(feature, spliced, cds) ;
}
else
{
dna = zMapFeatureGetFeatureDNA(context, feature) ;
dna = zMapFeatureGetFeatureDNA(feature) ;
}
if (dna)
if (!dna)
{
zMapWarning("%s", "No DNA available") ;
}
else
{
/* Would be better to have the dna functions calculate and return this.... */
seq_len = strlen(dna) ;
......@@ -644,46 +648,47 @@ static void peptideMenuCB(int menu_item_id, gpointer callback_data)
molecule_type = "Protein" ;
gene_name = (char *)g_quark_to_string(feature->original_id) ;
dna = zMapFeatureGetTranscriptDNA(menu_data->window->feature_context, feature, spliced, cds) ;
/* Adjust for when its known that the start exon is incomplete.... */
if (feature->feature.transcript.flags.start_not_found)
start_incr = feature->feature.transcript.start_phase - 1 ; /* Phase values are 1 <= phase <= 3 */
if ((dna = zMapFeatureGetTranscriptDNA(feature, spliced, cds)))
{
/* Adjust for when its known that the start exon is incomplete.... */
if (feature->feature.transcript.flags.start_not_found)
start_incr = feature->feature.transcript.start_phase - 1 ; /* Phase values are 1 <= phase <= 3 */
peptide = zMapPeptideCreate(seq_name, gene_name, (dna + start_incr), NULL, TRUE) ;
peptide = zMapPeptideCreate(seq_name, gene_name, (dna + start_incr), NULL, TRUE) ;
/* Note that we do not include the "Stop" in the peptide length, is this the norm ? */
pep_length = zMapPeptideLength(peptide) ;
if (zMapPeptideHasStopCodon(peptide))
pep_length-- ;
/* Note that we do not include the "Stop" in the peptide length, is this the norm ? */
pep_length = zMapPeptideLength(peptide) ;
if (zMapPeptideHasStopCodon(peptide))
pep_length-- ;
if (menu_item_id == ZMAPCDS || menu_item_id == ZMAPTRANSCRIPT || menu_item_id == ZMAPUNSPLICED)
{
char *title ;
char *peptide_fasta ;
if (menu_item_id == ZMAPCDS || menu_item_id == ZMAPTRANSCRIPT || menu_item_id == ZMAPUNSPLICED)
{
char *title ;
char *peptide_fasta ;
peptide_fasta = zMapFASTAString(ZMAPFASTA_SEQTYPE_AA, seq_name, molecule_type, gene_name,
pep_length, zMapPeptideSequence(peptide)) ;
peptide_fasta = zMapFASTAString(ZMAPFASTA_SEQTYPE_AA, seq_name, molecule_type, gene_name,
pep_length, zMapPeptideSequence(peptide)) ;
title = g_strdup_printf("%s%s%s",
seq_name,
gene_name ? ":" : "",
gene_name ? gene_name : "") ;
zMapGUIShowText(title, peptide_fasta, FALSE) ;
g_free(title) ;
title = g_strdup_printf("%s%s%s",
seq_name,
gene_name ? ":" : "",
gene_name ? gene_name : "") ;
zMapGUIShowText(title, peptide_fasta, FALSE) ;
g_free(title) ;
g_free(peptide_fasta) ;
}
else
{
dumpFASTA(menu_data->window, ZMAPFASTA_SEQTYPE_AA,
zMapPeptideSequence(peptide), seq_name,
pep_length, molecule_type, gene_name) ;
}
g_free(peptide_fasta) ;
}
else
{
dumpFASTA(menu_data->window, ZMAPFASTA_SEQTYPE_AA,
zMapPeptideSequence(peptide), seq_name,
pep_length, molecule_type, gene_name) ;
}
zMapPeptideDestroy(peptide) ;
zMapPeptideDestroy(peptide) ;
g_free(dna) ;
g_free(dna) ;
}
g_free(menu_data) ;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment